[Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1636
  • Last Modified:

WriteXML / WriteXMLSchema

I want to know:

(1) What is the difference between:

DataSet.Tables[0].WriteXML("File.XSD", XMLWriteMode.Schema)


DataSet.Tables[0].WriteXML Schema

(2) I already have .XSD files created with the above methods. But I am using above methods each time when the application is run. This is slowing reports. I therefore want to fill the existing XSD file but it should not create XML Schema again.
  • 3
  • 2
2 Solutions
there is a big difference between the two:

Use the WriteXmlSchema method to write the schema for a DataTable to an XML document. The schema includes table, relation, and constraint definitions.
Use the WriteXml method to write the data to an XML document.
check out readxmlschema method to read the schema definition..check out the sample code:

// Write the schema to XML in a memory stream.
    System.IO.MemoryStream xmlStream = new System.IO.MemoryStream();
    // Rewind the memory stream.
    xmlStream.Position = 0;
    DataTable newTable = new DataTable();

Open in new window

rpkhareAuthor Commented:
When I use "WriteXML", what if the XSD file already contains old data? Is it cleared on each fill?
xsd will have schema..there will no data. are you changing schema on every write..if not it should be ok.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

rpkhareAuthor Commented:
What if I write only:


and don't provide the XML write mode?
Bob LearnedCommented:
It may help to look at what happens in the .NET framework when you call the WriteXml with a file name:

public void WriteXml(string fileName)
    this.WriteXml(fileName, XmlWriteMode.IgnoreSchema, false);

Open in new window

rpkhareAuthor Commented:

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now