Click here to Skip to main content
15,908,775 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
I have xml like

<searchRQ name="edrdrd" idv="3">

<searchRQStr id="1" value="134erdfr">
<Name>MAULIK1</Name>
<LName>SHAH1</LName>
<RoolValue>ASWED11</RoolValue>
</searchRQStr>



<searchRQStr id="2" value="2134erdfr">
<Name>MAULIK2</Name>
<LName>SHAH2</LName>
<RoolValue>ASWED21</RoolValue>
</searchRQStr>





<searchRQStr id="3" value="3134erdfr">
<Name>MAULIK3</Name>
<LName>SHAH3</LName>
<RoolValue>ASWED31</RoolValue>
</searchRQStr>


<searchRQStr id="4" value="4134erdfr">
<Name>MAULIK4</Name>
<LName>SHAH4</LName>
<RoolValue>ASWED41</RoolValue>
</searchRQStr>







</searchRQ>

etc.................

I want to read all in dataset and display them directly into listview without itemtemplate</pre>

Pls give proper example code
Posted
Updated 3-Apr-14 0:13am
v3

Once you read your XML into a Dataset, you will have two tables (for your XML)

1. Table : searchRQ with 2 columns
2. Table : searchRQstr with 5 columns.

C#
string str = "C:\\XmlFile.xml";
            DataSet ds = new DataSet();
            ds.ReadXml(new System.IO.StreamReader(System.Security.SecurityElement.Escape(str), System.Text.Encoding.UTF8));
            DataTable searchRQ = ds.Tables[0];
            DataTable searchRQStr = ds.Tables[1];



C#
Table: searchRQ

name						idv
edrdrd						3

					
					
Table: searchRQStr					
					
id value	Name		LName	RoolValue	
1  134erdfr	MAULIK1		SHAH1	ASWED11	
2  2134erdfr	MAULIK2		SHAH2	ASWED21	
3  3134erdfr	MAULIK3		SHAH3	ASWED31	
4  4134erdfr	MAULIK4		SHAH4	ASWED41	
 
Share this answer
 
v2
You can convert your xml into dataset like so:
C#
String strXML = "Your xml";
DataSet ds = new DataSet();
ds.ReadXML(strXML);


If your XML is from a file then
C#
String strXMLFileName = "Your XML File Name";
DataSet ds = new DataSet();
ds.ReadXML(strXMLFileName);
 
Share this answer
 
Comments
maulikshah1990 3-Apr-14 7:51am    
yes..i have used above ...but how to read particular xml value from dataset
sid31988 8-Apr-14 6:32am    
I hope you are asking about reading values from dataset(created from xml). When your xml gets converted into dataset, it gets converted into DataTable, DataColumn and DataRow. So if you want to read a particular value it will be like:
string name = objDataSet.Tables[0].Rows[0]["Name"];
here i am reading the name from the first record, for further records you will need to iterate over objDataSet.Tables[0].Rows collection.
 
Share this answer
 
Comments
maulikshah1990 2-Apr-14 8:43am    
can u please give example code .. i saw above link..but that is complicated.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900