What classes are suitable for working with XML?

K

K Viltersten

I'll be working some XML's soon and i wonder if
it's recommended to develop own parsers or if
there exist good tools already in DotNet 3.0 or
3.5 under VS.NET 2005.

Once the XML has been read, should i parse it
to any particular data form? DataSet, i've
heard something about but perhaps there are
more suitable data structures. The XML's will
be rather shallow, with at most four levels.
 
J

Jon Skeet [C# MVP]

K Viltersten said:
I'll be working some XML's soon and i wonder if
it's recommended to develop own parsers or if
there exist good tools already in DotNet 3.0 or
3.5 under VS.NET 2005.

It's definitely *not* recommended for you to write your own parser.
There are plenty of good tools in .NET already. LINQ to XML is
particularly nice, IMO.
Once the XML has been read, should i parse it
to any particular data form? DataSet, i've
heard something about but perhaps there are
more suitable data structures. The XML's will
be rather shallow, with at most four levels.

That entirely depends on what you want to do with it.
 
A

Alberto Poblacion

K Viltersten said:
I'll be working some XML's soon and i wonder if
it's recommended to develop own parsers or if
there exist good tools already in DotNet 3.0 or
3.5 under VS.NET 2005.

Once the XML has been read, should i parse it
to any particular data form? DataSet, i've
heard something about but perhaps there are
more suitable data structures. The XML's will
be rather shallow, with at most four levels.

Don't bother writing your own parser. There are plenty of tools in the
Framework.

You may wish to look at the XmlDocument class, which implements the DOM
to manipulate your XML (and of course parses and loads the XML).
There are also the XmlReader and XmlWriter if you wnat to process your
Xml sequentially.
There is also the XmlSerializer, which can import or export XML into
classes designed to match the structure of the xml.
And then, in the Framework 3.5, you have XElement which is particularly
suited for querying your XML using LINQ.

You *can* load your XML into a DataSet, but not every XML file is
suitable for processing in this way. Most of the time you will only want to
load your XML into a DataSet if it represents one or more data tables.
 
K

K Viltersten

I'll be working some XML's soon and i wonder if
Don't bother writing your own parser. There are plenty of tools in the
Framework.
You may wish to look at the XmlDocument class, which implements the DOM to
manipulate your XML (and of course parses and loads the XML). There are
also the XmlReader and XmlWriter if you wnat to process your Xml
sequentially.

Thanks a lot to all who helped.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top