474,047 Members | 6,489 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 5498
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!P LEASEtkachenko. com> wrote in message
news:u9******** ******@TK2MSFTN GP09.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!P LEASEtkachenko. com> wrote in message
news:ut******** *****@TK2MSFTNG P11.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
1622
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 --> <!-- Test Comment 2 --> <Books> <Book> <Title>XML Book One</Title>
1
1731
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 "XPath-Navigable-Document" from my Nodelist wich I seem to need for the XSLTransform? This is the code...
2
1712
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" encoding="UTF-8" ?> <ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
1557
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 type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
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 returns null object. When I checked the response using xml document's outerXML property, I found...
8
6243
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
3815
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 XmlTextReader = New XmlTextReader(strXmlFeedUrl)
3
4994
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
11301
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 url='http://www.yahoo.com' /> </Internet>
0
10548
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
10343
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11604
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...
0
11145
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...
0
10316
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8701
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
6661
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
5423
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
4947
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.