473,811 Members | 3,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5788


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
4395
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" /> <row uniqueid="4322" />
2
2486
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 having problems doing same procedures I do with XPathDocuments in XPathDocuments. I have a configuration XML document, which holds all the configuration information for an application (see below sample). I extract the information from the...
2
13429
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 appreciated. --Ed
1
2268
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 resultset ... is working with an XPathDocument faster than working with an XMLDocument ? if so , how much faster ?
2
6045
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 XmlDocument TransformXmlDoc(XmlDocument docToTransform, string xsltFilePath) { //load the xslt
3
1442
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 need to supply the XmlDocument object (with the source tree loaded) and receive the output in string. Traditionally I do this thing in very simple way which is as below: dom.load "xmldoc.xml" sdom.load "xsldoc.xsl"
5
12690
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 might help me a lot. Thanks, Fahad
1
10165
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 article on extending the DOM, which seems to be exactly what I want, here: http://msdn2.microsoft.com/library/e3x60fe9(en-us,vs.80).aspx
5
6288
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 than XmlDocument. I've run the tests several times and have tried to eliminate extraneous variables like disk access but every time, XPathDocument comes up slower by a few percent. I'd expected it to be faster since it's a read-only...
0
9731
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10405
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4342
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.