XmlTextReader - practical application

  • Thread starter Thread starter Random
  • Start date Start date
R

Random

I have a very small XML file I am using to hold data for my app, and want
the fastest, easiest way to grab my data from it. On the surface it seems
the XmlTextReader is the best object for this, but I am having several
issues with it. All of the examples I can find simply iterate through all
the nodes and spit out the data. Well, I need to actually navigate to the
nodes and obtain the values stored there.

I've thought about using the XPathNavigator for this, but the documentation
suggests it is not as efficient as the Reader, and would still require
creating seperate Node objects.

Does anyone have any suggestions?
 
the XPathNavigator is the way to go if you need to navigate through the
document -- the other alternative would be to move it to a dataset and to
work from there...
 
If your XML document is small then use whatever API works best for you to
understand. I'd imagine you've used a DOM in the past, so XmlDocument is
the same in .NET. XmlReader is a forward-only read-only API for reading large/huge
documents when you want to avoid the XmlDocument overhead (since it reads
everything into memory). XPathDocument is a readonly API that you use with
XPathNavigator for queries and is very efficient compared to XmlDocument
when you're working with large XML. XmlDataDocument gives you a treeview
(normal XML DOM) or a DataSet/DataTable view on your XML if you need that,
but otherwise I'm not a huge fan of it.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Back
Top