473,378 Members | 1,429 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

xmldocument vs. xpathdocument

Hi,

Could someone explain the functional difference between these classes? From
what I understand, xpathdocument is faster in some scenarios, but I'm not
sure why. Further, why is it that the method of getting xml data into these
two classes differs? (xmldocument uses the load method, whereas xpathdocument
doesn't have this available and one must specify the path to the xml data in
the constructor, or so it seems). Any help would be appreciated. Thanks...

-Ben
Nov 12 '05 #1
5 5766


Ben R. wrote:

Could someone explain the functional difference between these classes? From
what I understand, xpathdocument is faster in some scenarios, but I'm not
sure why.


XmlDocument implements a document object model which allows reading out
data from the document and changing the document (changing the value of
an attribute, changing the contents of a text node, inserting nodes,
removing nodes).
XPathDocument allows a read only access to an XML document.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Thanks for the quick response, Martin. Any idea about why there's 2 different
ways to get the xml data into the two classes?

-Ben

"Martin Honnen" wrote:


Ben R. wrote:

Could someone explain the functional difference between these classes? From
what I understand, xpathdocument is faster in some scenarios, but I'm not
sure why.


XmlDocument implements a document object model which allows reading out
data from the document and changing the document (changing the value of
an attribute, changing the contents of a text node, inserting nodes,
removing nodes).
XPathDocument allows a read only access to an XML document.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Nov 12 '05 #3


Ben R. wrote:
Any idea about why there's 2 different
ways to get the xml data into the two classes?


One reason could be an attempt to keep the methods that MSXML implements
for DOM documents, there a DOM document has a load method and a loadXML
method and the DOM XmlDocument in .NET has those two methods too. But
that is just a guess, only the API designers can tell why they did that.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #4
Ben R. wrote:
Thanks for the quick response, Martin. Any idea about why there's 2 different
ways to get the xml data into the two classes?


A reason could be that, if you're using XPathDocument, you allways have
to load XML, as read-only would have no sense if you did not load
anything. But the XmlDocument allows you to create XML from scratch,
without having to load anything. You also can reuse it, load something,
modify it, save it somewhere, modify it, safe it again, load something
else...

But it would be nice to have a Constructor of XmlDocument wich acts like
those of XPathDocument, it's one line of code less... :)
Nov 12 '05 #5
Ben R. wrote:
Thanks for the quick response, Martin. Any idea about why there's 2 different
ways to get the xml data into the two classes?


XmlDocument and XPathDocument are based on different data models.
XmlDocument is based on W3C XML DOM, which is object model that
basically covers all XML syntax, including low level syntax sugar such
as entities, CDATA sections, DTD, notations etc. That's document-centric
model and it allows for full fidelity when loading/saving XML documents.

XPathDocument is based on XPath 1.0 data model which is read-only XML
Infoset-compatible data-centric object model that covers only
semantically significant parts of XML, leaving out insignificant syntax
details - no DTD, no entities, no CDATA, no adjacent text nodes, only
significant data expressed as a tree with seven types of nodes. Simple
and lightweight.
That's why XPathDocument is preffered data store for read-only
scenarios, especially with XPath or XSLT involved.

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.xmllab.net
http://blog.tkachenko.com
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ian Lawton | last post by:
Hi, in a C# app, I have an XPathDocument that looks similar to this: <row uniqueid="4234" /> <row uniqueid="4365" /> <row uniqueid="3124" /> <row uniqueid="9879" /> <row uniqueid="1332" />...
2
by: Jim Lewis | last post by:
After everything I have read and some of my own testing I am convinced that XPathDocument are more efficient if you are only using XML for read only and not modifying the XML. However, I have been...
2
by: Ed S | last post by:
Hi All, I'd like to convert from an XmlDocument to an XPathDocument (without saving the XmlDocument down to a file - this is a web app). I can't see any way to do this. Any help is...
1
by: John A Grandy | last post by:
working with a local xml file. perform an xpath query and iterate through the resultset to build a virtual DataTable -- each DataRow composed of multiple attributes of each element in the xpath...
2
by: Graham Pengelly | last post by:
Hi I am trying to transform on System.Xml.XmlDocument into another using XslTransform without writing the object out to a file. I am guessing it should work something like this... public...
3
by: Fahad Ashfaque | last post by:
Hi, I found the XSL Transformation through .NET too complex. The most simplest overload of System.Xml.Xsl.XslTransform is Transform(inputfile, outputfile), but this saves the result into file. I...
5
by: Fahad Ashfaque | last post by:
Hi, I've an object of XmlDocument, I need to pass it to some function which takes XpathDocument object, How could I convert? There is not Conversion Operator overload like that. Your reply...
1
by: Greg Allen | last post by:
Is there a way to get line number information from an XmlDocument object? As I work with the various elements in the XmlDocument, I want to be able to refer to the line number. I found an...
5
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I've been trying to improve the performance of our xml handling, so I've been doing some timing tests lately and ran across something I thought odd - XPathDocument seems slightly slower...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.