XGIS
asked on
Export XML using C# as Attribute Rows
I need my exports to look like this;
<?xml version="1.0" encoding="utf-8" ?>
<Items>
<Item Name="Afghanistan" ID="296" />
<Items>
and NOT this (as they are now)<?xml version="1.0" standalone="yes"?>
<Items>
<Item>
<ID>296</ID>
<Name>Afghanistan</Name>
</Item>
My export Code is this;
var adapter4 =
new SqlDataAdapter("SELECT [Name],[ID],[PID1] FROM dbo.Countries where PID1 = 14 ORDER BY Name ASC", connection);
var dt4 = new DataTable("Item");
adapter4.Fill(dt4);
DataSet ds4 = new DataSet("Items");
ds4.Tables.Add(dt4);
ds4.WriteXml("C:\\inetpub\\wwwroot\\XR8\\App_Data\\XML\\Countries.xml", System.Data.XmlWriteMode.IgnoreSchema);
What am I missing? Please advise?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I did try a for each but obviously not the right way. Excellent Job.. it data-binded immediately.
Thankyou
Aaron