Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml to dataset and back

Status
Not open for further replies.

ludmann

Programmer
Apr 14, 2004
49
GB
I need to convert from DataSet to XML and back. I use the WriteXML() in C#. When a field(s) in a dataset is empty, there will be no equivalent xml tag in the xml file.

I am not sure what happens when it is converted back?

For example I might get:

<books>
<book>
<title>J2ME</title>
<author>Sun</author>
<isbn>8997766</isbn>
</book>
<book>
<title>MS Outlook</title>
</book>
<book>
<title>C# cookbook</title>
<isbn>6778887</isbn>
</book>
</books>

Whereas I really need:

<books>
<book>
<title>J2ME</title>
<author>Sun</author>
<isbn>8997766</isbn>
</book>
<book>
<title>MS Outlook</title>
<author></author>
<isbn></isbn>
</book>
<book>
<title>C# cookbook</title>
<author></author>
<isbn>6778887</isbn>
</book>
</books>

Does anyone know how?

thank you

 
there should be no problem if you write the schema too
 
I am quite new to this. I Realise I can use the WriteXMLSchema() to create the schema from the DataSet.

So do I create the XML Schema first and then include it in the xml that is to be generated? How do I include?

or how do I apply the schema to the XML

Marika
 
there's another thread called "returning hierarchical XML..." take a look there.
 
Thanks,
My code still looks like as above, however it inserted the xml schema in top of the xml file.
Hopefully this will work.

I don't really know enough about the topic, so I guess I will just have to play around with it.

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top