To start, create a C# windows Forms Application, and create a form as shown below:

*Note: by default, the three textboxes should be named textBox1, textBox2, textBox3.

As you can see, we will load three items for each computer, Type, Amount of RAM, and the CPU Speed.
Now add an "open file dialog" to our project, to allow the user to open a "computer specifications xml file".

To get started, we will set up the loading part of our program, go into code view of Form1.h, and add the following using references:

using System.Xml;
using System.IO;

Reading and parsing xml content

To read and parse the xml file, we will:

Create a file stream

Create an XmlDocument that will read the filestream

Parse the XmlDocument

Display the InnerText of the Nodes with the needed information in it

First, go back into design mode, and double-click the "Load" Button, to create an onclick() event. In the newly created event, insert this code:

CompSpecs.Load(READER); //Load the data from the file into the XmlDocument (CompSpecs) //

Hey, this is a great little tutorial, exactly what I was looking for to help build an XML reader for a couple of Adobe forms that I've made in my office. The only trouble is with that particular line of code quoted above: it is giving me an error. it occurs once I test run the program, I'll click load and get the dialog box. I'll double-click my xml file and the following is the error it gives me:

XmlException was unhandled.
Data at the root level is invalid. Line 8, position 13.

If it helps, I'm using Microsoft Visual C# 2008 Express Edition. I'm also looking elsewhere for solutions, but as this is literally my first programming experience, I'm having trouble finding anything useful.

I was getting that same error, it you open the xml file in notepad you will see that for some reason "cs>" has been added to the <CompSpecs> endtag </CompSpecs>cs>, therefore the root element has been made invalid.

I dont know why this happens when you save the file sometimes, but if you delete the cs> off from the endtag then the program will work fine again.

Bizzare error but perhaps need to test for that and remove it in the load click event.