To clarify Thomas' point, the DataSet itself does not contain a DOM, but
rather can be represented as a DOM using XmlDataDocument.  XmlDataDocument,
however, sets an internal member variable to the DataSet as well as deriving
from XmlDocument:  the XmlDocument not only keeps the DataSet in memory, but
also inherits the memory requirement of the XmlDocument class.  

In context of Torsten's post, I have not noticed any type of discernable
performance difference between a DataTable.Select or an XPath expression.
The selection of the items and their performance should be negligible,
assuming that you are using efficient XPath queries (ie, avoiding "//").  

I would not consider using the XmlDataDocument:  it is fairly well
documented that XmlDataDocument gives poor performance for XPath queries.
So, the real determining factor should be the memory overhead for the object
representation itself.  

If you need XPath, use an XPathNavigator over an XmlTextReader to give the
best performance and minimizes the working set overhead.  If you need to
perform CRUD on XML, then consider XmlDocument.  It uses more memory to
represent the hierarchy of objects, but allows updating where XPathNavigator
does not.  If you need relational behavior, interaction with the database,
etc, choose the DataTable.  

You can also intermix approaches fairly easily.  You can use an
XmlTextReader to find a branch of a much larger XML document, then load only
that branch into memory using XmlDocument.  Update the XmlDocument
appropriately, then write the resulting changes into an XmlTextWriter.  The
XmlTextWriter can be built upon a stream, so you set the Stream's position
to 0, and use the stream for the ctor for a DataSet.  Point the DataSet at a
DataAdapter, and you can update the database with the changes.

Kirk Allen Evans
Author, "XML And ASP.NET", New Riders Publishing
www.xmlandasp.net
Read my web log at http://www.dotnetweblogs.com/kaevans


> -----Original Message-----
> From: Moderated discussion of advanced .NET topics. [mailto:ADVANCED-
> [EMAIL PROTECTED] On Behalf Of Thomas Tomiczek
> Sent: Friday, June 06, 2003 10:53 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [ADVANCED-DOTNET] How expensive is XmlDataDocument
> 
> Well, no clue about speed, BUT memory wise:
> 
> The DataSet (above an XML document) is built on top o fan
> XmlDataDocument DOM like presentation, so it uses more memory than the
> DOM presentation.
> 
> Regards
> 
> Thomas Tomiczek
> THONA Consulting Ltd.
> (Microsoft MVP C#/.NET)
> 
> 
> 
> >
> > -----Original Message-----
> > From: Torsten Kramer [mailto:[EMAIL PROTECTED]
> > Sent: Freitag, 6. Juni 2003 15:16
> > To: [EMAIL PROTECTED]
> >
> > Hi,
> >
> > I've one of these very pretty DataSet instances. But I don't
> > want to use SQLs select syntax to query my DataSet, I want to
> > use XPath. Therefore I attach my DataSet to an XmlDocument
> > and use SelectSingleNode or even the methods of
> > IXPathNavigator. But what does this cost with respect to
> > performance and memory consumption? What is faster -
> > DataTable.Select or XmlDocument.SelectNode/SelectSingleNode?
> >
> > Who can enlighten me?
> >
> > Torsten
> >
> >

Reply via email to