471,312 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,312 software developers and data experts.

Simple question about ReadXml and WriteXml

Hello!

Assume the following :
1. I create a DataSet with some DataRelation.
2. I then use WriteXml to write the DataSet to an Xml document using
DataRelation.Nested = True
3.I then read the Xml document using ReadXml to load and create a DataSet.

Now to my question is this DataSet that was created from 3 the same DataSet
with the same structure
that existed when I wrote down using WriteXml using point 2 above.

//Tony
Aug 25 '08 #1
2 1571
"Tony Johansson" <jo*****************@telia.comwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
Assume the following :
1. I create a DataSet with some DataRelation.
2. I then use WriteXml to write the DataSet to an Xml document using
DataRelation.Nested = True
3.I then read the Xml document using ReadXml to load and create a DataSet.

Now to my question is this DataSet that was created from 3 the same
DataSet
with the same structure
that existed when I wrote down using WriteXml using point 2 above.
In step 3 you will only be sure to get an accurate duplicate of the
schema of the original dataset if you use the "WriteSchema" option when you
do the WriteXml in step 2:

myDataSet.WriteXml("file.xml", XmlWriteMode.WriteSchema);

This adds an xsd schema at the beginning of the written file, which can
then be used by ReadXml to reconstruct the original schema before loading
the data that follow. You can open the file with an editor to verify whether
the DataRelation does make its way into the schema (I believe it does).

Aug 25 '08 #2
On Aug 25, 8:02*am, "Tony Johansson" <johansson.anders...@telia.com>
wrote:
Hello!

Assume the following :
1. I create a DataSet with some DataRelation.
2. I then use WriteXml to write the DataSet to an Xml document using
DataRelation.Nested = True
3.I then read the Xml document using ReadXml to load and create a DataSet..

Now to my question is this DataSet that was created from 3 the same DataSet
with the same structure
that existed when I wrote down using WriteXml using point 2 above.

//Tony
IIRC you will have the exact same dataset. the only difference is how
the rows of the child table are created. If nested=true they are
embedded in the parent table.

honestly unless you will use the XML generated file in any other way I
would set nested to false
Aug 25 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Brian Henry | last post: by
reply views Thread by John George | last post: by
2 posts views Thread by C Glenn | last post: by
1 post views Thread by ray well | last post: by
reply views Thread by =?Utf-8?B?bXJjc2hhcnBtYW4=?= | last post: by
reply views Thread by Arto Viitanen | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.