Since each node is a different name, the default DataSet import method puts them in different tables. If you look at ds in the debugger, you will notice it has a table for residential, commercial, residential_apartment_flat, etc.
If you want them all to be rows in the same table, change all the nodes to the same name and make the "residential/commercial/etc." parts be attributes.
vikram shah
Member
88 Points
261 Posts
ReadXml ()
Nov 19, 2012 09:17 AM|LINK
<?xml version="1.0" encoding="utf-8" ?>
<limits>
<residential
MinArea="10" MaxArea="100000" MinPrice="100" MaxPrice="1000000" MinRent="10" MaxRent="7500" />
<commercial
MinArea="5" MaxArea="500000" MinPrice="100" MaxPrice="1000000" MinRent="10" MaxRent="7500" />
<residential_apartment_flat
MinArea="20" MaxArea="2500" MinPrice="1000" MaxPrice="1000000" MinRent="15" MaxRent="5000" />
<residential_independent_house
MinArea="25" MaxArea="10000" MinPrice="1000" MaxPrice="1000000" MinRent="12" MaxRent="4000" />
<residential_hostel
MinArea="50" MaxArea="10000" MinPrice="1000" MaxPrice="1000000" MinRent="12" MaxRent="2500" />
<residential_paying_guest
MinArea="10" MaxArea="1000" MinPrice="1000" MaxPrice="1000000" MinRent="10" MaxRent="1000" />
<residential_guest_house
MinArea="10" MaxArea="10000" MinPrice="1000" MaxPrice="1000000" MinRent="12" MaxRent="5000" />
<residential_vacation_rental
MinArea="10" MaxArea="10000" MinPrice="1000" MaxPrice="1000000" MinRent="12" MaxRent="7500" />
</limits>
protected void Button2_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("/XMLFILES/PropertyLimits.xml"));
GridView1.DataSource = ds;
GridView1.DataBind();
}
Why only one row in the output and not all of the xml data above ?
Output is:
DarrellNorto...
All-Star
86773 Points
9643 Posts
Moderator
MVP
Re: ReadXml ()
Nov 19, 2012 09:51 AM|LINK
Since each node is a different name, the default DataSet import method puts them in different tables. If you look at ds in the debugger, you will notice it has a table for residential, commercial, residential_apartment_flat, etc.
If you want them all to be rows in the same table, change all the nodes to the same name and make the "residential/commercial/etc." parts be attributes.
For example this XML would work:
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
vikram shah
Member
88 Points
261 Posts
Re: ReadXml ()
Nov 19, 2012 10:27 AM|LINK
Can you tell me how to automatically generate Id for the xml data.
Any links with more details can be helpful.
Thanks.