473,520 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XPath helper upon XmlTextReader

I do like XPath, I really do.

But I'm working on the compact framework which XPath is not included.

So I come to understanding that if XPath do not come to the mountain,

The mountain will come to XPath.

I decided to build an XPath evaluation helper with will get XmlTextReader
and XPath string, and it will return XmlTextReader that will be the result
of the XPath.

The signature should be something like that:

XmlTextReader XPathHelper (XmlTextReader reader, string xpath)

The thing that I'm querying the community is does a similar code already
exist on the internet, and I'm going to spend my time on an existing issue.

Any way I will be glad to hear if you have a suggestion for the architecture
of such helper.

I thought of something simple which will ignore ancestor axis for the start.

And it seems to me like a recursive method which dealing with one operation
at a time and then recurs the call with the result reader and the XPath
ahead of the already handled operation.

Which mean the "//Book/Author[@name='Mike']" XPath will:

1.. Iterate around all Book tags
2.. forward the result reader with the " /Author[@name='Mike']" ahead
3.. Iterate around all Author tags
4.. forward the result reader with the " [@name='Mike']" ahead
5.. then return reader if there is attribute "name='Mike'" else return
null
Nov 12 '05 #1
4 5465
Bnaya Eshet wrote:
So I come to understanding that if XPath do not come to the mountain,

The mountain will come to XPath.


Take a look at recently published "The Best of Both Worlds: Combining
XPath with the XmlReader" article by Dare Obasanjo and Howard Hao -
http://msdn.microsoft.com/library/en...ml05192004.asp

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
As I mention I'm using the Compact Framework which do not have support for
XpathReader so that article does not supplying the right answer.

TNX any way

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:u9**************@TK2MSFTNGP09.phx.gbl...
Bnaya Eshet wrote:
So I come to understanding that if XPath do not come to the mountain,

The mountain will come to XPath.


Take a look at recently published "The Best of Both Worlds: Combining
XPath with the XmlReader" article by Dare Obasanjo and Howard Hao -
http://msdn.microsoft.com/library/en...ml05192004.asp

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

Nov 12 '05 #3
Bnaya Eshet wrote:
As I mention I'm using the Compact Framework which do not have support for
XpathReader so that article does not supplying the right answer.


No, read the article. It describes implementation of XPath over plain
XmlTextReader (which is supported in the CF).

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #4
Beware, however, that it's based on the same core of XPath in .NET (though I
wonder why it's not included in CF... maybe it's too computationally
expensive? - build AST, keep the whole thing in-memory, advance the
cursor...).
Watch out the licensing terms if you're going to distribute/sell it, as it's
the MS's Shared Source.

--
Daniel Cazzulino [MVP XML]
Clarius Consulting SA
http://weblogs.asp.net/cazzu
http://aspnet2.com

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:ut*************@TK2MSFTNGP11.phx.gbl...
Bnaya Eshet wrote:
As I mention I'm using the Compact Framework which do not have support for XpathReader so that article does not supplying the right answer.


No, read the article. It describes implementation of XPath over plain
XmlTextReader (which is supported in the CF).

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.679 / Virus Database: 441 - Release Date: 07/05/2004
Nov 12 '05 #5

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

Similar topics

1
1599
by: david_b_mcconnell | last post by:
Hi, I am having a problem using XPath when I validate Xml documents with a schema. Basically what happens is that an XPath query doesn't return the nodes I require if a schema is used to validate the XML. I'll try and explain it as briefly as possible here. For example, look at the following XML. <?xml version="1.0"?> <!-- Test Comment -->...
1
1707
by: Chucker | last post by:
I would like to select some nodes from a very large XML document and then apply a stylesheet to the dom fragment / nodelist that is the result of my XPath-Query. It seems to me now that I have to build a new XMLDocument from the Nodelist and apply the Stylesheet then. Is this realy neccessary or is there a simple way to generate an...
2
1695
by: Someone | last post by:
Using C#, ASP.NET I'm trying to implement Yahoo search API. I can sent the HTTP request and get back the results. The problem I have is that I don't know how to use XPath with the results than comes back. I coded XPath before successfully, but Yahoo XML is a bit more complex. Here is part of Yahoo XML result: <?xml version="1.0"...
2
1540
by: Richard | last post by:
Hi, I am trying to use an XmlDocument object to manipulate the default database instance node of the enterprise template library dataConfiguration section from a custom installer step: <?xml version="1.0" encoding="utf-8"?> <dataConfiguration> <xmlSerializerSection...
0
331
by: Bravo | last post by:
Hi I am trying to call a web page to get xml response back using xmlWebRequest and HTTPWebResponse classes. After getting the response, I am loading it in to a xmlDocument for further processing. I am using XPath to verify and get results from XML Document. Problem is, when I use the Xpath expression, eventhough document has value in it, it...
8
6217
by: Joe Pannone | last post by:
Does anyone have an example on using an XPath statement (in VB.NET) where the source XML document is NOT a file, but a 'text' value from SQL Server?
4
3792
by: amessimon | last post by:
Hi, im trying to use the Xpath function "reverse" with an XmlTextReader. Im not sure if i need to add a namespace to reference this function or what, if so whats the address of the namespace. Can anyone give me an idea where i am going wrong here? So far.... Dim strXmlFeedUrl As String = server.mappath("test.xml") Dim reader As...
3
4960
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml version="1.0" encoding="utf-8" ?> <thing xmlns="urn:thing-schema-v1"> <foo>foo thing</foo> <bar>bar thing</bar>
1
11263
by: BillGatesFan | last post by:
Does anyone have any code to get Attributes of an XML Element Using XPATH. I have been trying all day and cannot get this to work. I have been using XPathNavigator, XPathDocument and the XPathNodeIterator trying to get the url attribute of the following XML: <?xml version='1.0' encoding='utf-8' ?> <Message> <Internet> <site...
0
7299
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...
1
7163
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...
0
7559
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...
0
5740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5125
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...
0
4788
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...
0
3279
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
506
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.