472,981 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,981 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 5747


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...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.