WriteXML / WriteXMLSchema

I want to know:

(1) What is the difference between:

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

and

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.
LVL 8
rpkhareAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SameerJagdaleCommented:
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();
    table.WriteXmlSchema(xmlStream);
 
    // Rewind the memory stream.
    xmlStream.Position = 0;
 
    DataTable newTable = new DataTable();
    newTable.ReadXmlSchema(xmlStream);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rpkhareAuthor Commented:
When I use "WriteXML", what if the XSD file already contains old data? Is it cleared on each fill?
0
SameerJagdaleCommented:
xsd will have schema..there will no data. are you changing schema on every write..if not it should be ok.
0
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference ithrough the Colors of STEM program.

rpkhareAuthor Commented:
What if I write only:

DataSet1.Tables[0].WriteXML(XSDName)

and don't provide the XML write mode?
0
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

0
rpkhareAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.