473,394 Members | 1,787 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,394 software developers and data experts.

Best approach for xpath on .NET 2.0

Hi;

I need to perform xpath queries on xml under .net 2.0 (ok if it won't run
under 1.1). What is the approach that will give me the fastest code?

These xpath queries will walk all over the xml - it is not a case where each
query usually occurs further down the xml from the previous query. And there
will tend to be a lot of queries on each dataset.

--
thanks - dave
Nov 12 '05 #1
9 2630
Hi Dave,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to perform an XPath query on a
DataSet. If there is any misunderstanding, please feel free to let me know.

Here is a very good article dedicated on how to perform an XPath query on a
DataSet. Please check it and it will be helpful.

http://msdn2.microsoft.com/en-us/library/89tyw6dw

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #2
Hello;

Sorry - I should not have used the word dataset. My xml will always come
from a Stream - usually a file.

--
thanks - dave
"Kevin Yu [MSFT]" wrote:
Hi Dave,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to perform an XPath query on a
DataSet. If there is any misunderstanding, please feel free to let me know.

Here is a very good article dedicated on how to perform an XPath query on a
DataSet. Please check it and it will be helpful.

http://msdn2.microsoft.com/en-us/library/89tyw6dw

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #3
Hi dave,

Doing XQuery in an XmlDocument is generally the same as mentioned in the
article I have provided. If you're getting the xml from a file, you can
first load it into an XmlDocument and then use XmlDocument.SelectNodes with
an xpath as argument to do the query. It is also the same as we did in .NET
1.1. Please also check the following link for more informatioin on
SelectNodes method.

http://msdn2.microsoft.com/en-us/library/hcebdtae

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #4
Hello;

So XmlDocument is more efficient than XpathDocument? Ok, will go that route.

Out of curiosity why do they have XpathDocument then?

--
thanks - dave
"Kevin Yu [MSFT]" wrote:
Hi dave,

Doing XQuery in an XmlDocument is generally the same as mentioned in the
article I have provided. If you're getting the xml from a file, you can
first load it into an XmlDocument and then use XmlDocument.SelectNodes with
an xpath as argument to do the query. It is also the same as we did in .NET
1.1. Please also check the following link for more informatioin on
SelectNodes method.

http://msdn2.microsoft.com/en-us/library/hcebdtae

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #5

David Thielen wrote:
So XmlDocument is more efficient than XpathDocument?


No, XPathDocument is optimized for readonly XPath access. You only need
XmlDocument if you want to make changes to the XML.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #6
Hi;

That's what I thought. But Kevin Yu is, I am assuming, posting the official
MS suggestion. Any idea why he would prefer XmlDocument?

My use is xpath quieries only - so it is read-only.

--
thanks - dave
"Martin Honnen" wrote:

David Thielen wrote:
So XmlDocument is more efficient than XpathDocument?


No, XPathDocument is optimized for readonly XPath access. You only need
XmlDocument if you want to make changes to the XML.
--

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

Nov 12 '05 #7
Hi dave,

I think there might be some misunderstanding here. Using XmlDocument or
XpathDocument depends on the scenario. As Martin said, in an readonly case,
we can use xpathdocument, however, if you need to do modifications, use
XmlDocument.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #8
Hi;

Can I assume that for the read-only case XpathDocument is faster?

--
thanks - dave
"Kevin Yu [MSFT]" wrote:
Hi dave,

I think there might be some misunderstanding here. Using XmlDocument or
XpathDocument depends on the scenario. As Martin said, in an readonly case,
we can use xpathdocument, however, if you need to do modifications, use
XmlDocument.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #9
David Thielen wrote:
Can I assume that for the read-only case XpathDocument is faster?


Sure. It's 30-50% faster than XmlDocument for XPath. Not to mention it
takes less memory.

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

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

Similar topics

11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
10
by: Rich Wallace | last post by:
Hey all, I have an XML doc that I read into a SQL Server database from an integration feed.... ----------------XML snippet ---------------- <?xml version="1.0" encoding="us-ascii"?>...
2
by: chris.millar | last post by:
The class below uses the switch clause in the GetXSLT method. I want it to code it with a more OO approach does anyone have any suggestions, or change to make. cheers using System; using...
2
by: Scott M. Lyon | last post by:
I'm trying to figure out the best way (considering there could be instances where I get a lot of data in this XML, and I want to minimize any slowdowns) to extract the value of one particular node...
2
by: Eddie | last post by:
I have a DataSet with relations and other constraints being populated from the backend (SQL Server 2005). I use DataSet.FillSchema to retrieve the table schema for each table in the dataset. I...
1
by: monomaniac21 | last post by:
Hi all I need to use some Ajax for a site running PHP, I was wondering which is the best xml parser to use? regards Marc
9
by: Yehia A.Salam | last post by:
Hello, I am building an ASP.net website that connects to an XML database, and was wondering which is the best way to create the connection if I need frequent access to the database, I have one...
4
by: ink | last post by:
Hi all, I am trying to pull some financial data off of an HTML web page so that I can store it in a Database for Sorting and filtering. I have been thinking about this for some time and trying...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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...

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.