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.
Who is Participating?
SameerJagdaleConnect With a Mentor Commented:
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.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

rpkhareAuthor Commented:
What if I write only:


and don't provide the XML write mode?
Bob LearnedConnect With a Mentor Commented:
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:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.