Using Datasets to work with XML

This is the easy way. I’ll post other ways later.

  1. Make a mockup well formed XML file.
  2. From Visual Studio 2003, open the XML and right click on the open document. Select Create Schema. This creates an XSD file.
  3. You can edit values of specific part of the schema at this time. Only edit the properties section tagged “Misc”. Touching the dataset section will break the ability to generate the code behind the XSD.
  4. If you add the XSD namespace to the root element of the XML file, while both the XML and XSD are in your project, you will get intellisence for editing the XML.
  5. Once you are finished editing the XSD, you can right click on the XSD in the editor and select “Generate Dataset”

Now you have a type strong XML editor for your XML document.

Your next step is reading an writing. to read the XML into the dataset just type in yourdatasetname.ReadXML(“C:\somepath”)

To write the XML back out, type yourdatasetname.WriteXML(“C:\somepath”)

That is it in a nut shell. I’ll post more soon.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.