By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,236 Members | 2,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,236 IT Pros & Developers. It's quick & easy.

Loosing XML Schema when writing DataSet to XML

P: n/a
Hi,

//Returns a new dataset with tree datatables.
dsTemp.ReadXmlSchema(@"C:\mysch.xsd");

//Add a row to data table 0
DataRow dr = dsTemp.Tables[0].NewRow();
dr["field1"] = "value1";
dsTemp.Tables[0].Rows.Add(dr);

//write dataset to xml
System.IO.StringWriter stream = new System.IO.StringWriter();
dsTemp.WriteXml(stream);
string xmlTemp = stream.ToString();

When writing to xml, it looses schema information. The output xml is
not competible with mysch.xsd which has been read at first.

What would be the reason?

Thanks.

Ertan

Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ertan,

Have you tried the overload of WriteXml that takes a value from the
XmlWriteMode enumeration? You would want to pass the WriteSchema value to
the method.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<er********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi,

//Returns a new dataset with tree datatables.
dsTemp.ReadXmlSchema(@"C:\mysch.xsd");

//Add a row to data table 0
DataRow dr = dsTemp.Tables[0].NewRow();
dr["field1"] = "value1";
dsTemp.Tables[0].Rows.Add(dr);

//write dataset to xml
System.IO.StringWriter stream = new System.IO.StringWriter();
dsTemp.WriteXml(stream);
string xmlTemp = stream.ToString();

When writing to xml, it looses schema information. The output xml is
not competible with mysch.xsd which has been read at first.

What would be the reason?

Thanks.

Ertan

Nov 17 '05 #2

P: n/a
Nick,

WriteSchema enum value forces WriteXml method write only the schema
information, not the data.

Thanks anyway.

Nicholas Paldino [.NET/C# MVP] yazdi:
Ertan,

Have you tried the overload of WriteXml that takes a value from the
XmlWriteMode enumeration? You would want to pass the WriteSchema value to
the method.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<er********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Hi,

//Returns a new dataset with tree datatables.
dsTemp.ReadXmlSchema(@"C:\mysch.xsd");

//Add a row to data table 0
DataRow dr = dsTemp.Tables[0].NewRow();
dr["field1"] = "value1";
dsTemp.Tables[0].Rows.Add(dr);

//write dataset to xml
System.IO.StringWriter stream = new System.IO.StringWriter();
dsTemp.WriteXml(stream);
string xmlTemp = stream.ToString();

When writing to xml, it looses schema information. The output xml is
not competible with mysch.xsd which has been read at first.

What would be the reason?

Thanks.

Ertan


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.