Hi Mark,
As for the XPathDocument, it has different implementation internally. You
can use reflector to check its constructor. It use an Additional
XPathDocumentBuilder and the loading process is also a bit more complex
than the XmlDocument. I think this is probably due to the specific
implementation required for XPathNaviagtor generation.
For your scenario, if you haven't particular XPath based navigation
requirement, a normal XmlDocument is enough for standard DOM based
read/edit.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.--------------------
>From: =?Utf-8?B?TWFyaw==?= <mm******@nospam.nospam>
Subject: XmlDocument vs XPathDocument performance
Date: Thu, 5 Jun 2008 08:56:03 -0700
>
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 representation. Am I
doing something wrong?
start = Timers.QueryPerformanceCounter();
for (int idx = 0; idx < 50000; idx++)
{
StringReader sr = new StringReader(xmldoc);
doc = new XmlDocument();
doc.Load(sr);
}
start = Timers.SinceMilliSeconds(start);
Console.WriteLine(start);
start = Timers.QueryPerformanceCounter();
for (int idx = 0; idx < 50000; idx++)
{
StringReader sr = new StringReader(xmldoc);
pDoc = new XPathDocument(sr);
}
start = Timers.SinceMilliSeconds(start);
Console.WriteLine(start);
In other tests, XPathDocument seemed to improve
XslCompiledTransform.Transform performance very slightly, but not enough
to
>justify the switch given that the loading seemed more expensive...
Thanks
Mark