473,403 Members | 2,366 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,403 software developers and data experts.

Using Xpath functions?

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)
Dim xmlDoc = New XmlDocument
xmlDoc.Load(reader)
Dim urlArticleNodes As XmlNodeList =
xmlDoc.SelectNodes("reverse(/Articles/Article)")

Im getting the error...

"Namespace Manager or XsltContext needed. This query has a prefix,
variable, or user-defined function."

Thanks in advance.
Jan 30 '06 #1
4 3779


amessimon wrote:
im trying to use the Xpath function "reverse" with an XmlTextReader.


XPath 1.0 does not define any such function of that name:
<http://www.w3.org/TR/xpath#corelib>
..NET 1.x and 2.0 only supports XPath 1.0 and a few Microsoft extensions,
those for .NET 2.0 are listed here:
<http://msdn2.microsoft.com/en-us/library/ms256138(en-US,VS.80).aspx>
I guess you have been fooled by someone documentating XPath 2.0
functionality
<http://www.w3.org/TR/xquery-operators/#func-reverse>
without making it clear that the version is XPath 2.0 and that XPath 2.0
is not even a W3C recommendation (read: standard) but only on its way to
standardization.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 30 '06 #2
Thanks for pointing that Martin. Basically i am looking to order the
nodes i am selecting in the reverse order they appear in the document.

I would not be ordering by any particular node or attribute, just the
reverse of the order in the document.

eg: "/Articles/Article" in reverse order

Does anyone know a way to do this?

Martin Honnen wrote:


amessimon wrote:
im trying to use the Xpath function "reverse" with an XmlTextReader.


XPath 1.0 does not define any such function of that name:
<http://www.w3.org/TR/xpath#corelib>
.NET 1.x and 2.0 only supports XPath 1.0 and a few Microsoft extensions,
those for .NET 2.0 are listed here:
<http://msdn2.microsoft.com/en-us/library/ms256138(en-US,VS.80).aspx>
I guess you have been fooled by someone documentating XPath 2.0
functionality
<http://www.w3.org/TR/xquery-operators/#func-reverse>
without making it clear that the version is XPath 2.0 and that XPath 2.0
is not even a W3C recommendation (read: standard) but only on its way to
standardization.

Jan 30 '06 #3


amessimon wrote:
I would not be ordering by any particular node or attribute, just the
reverse of the order in the document.

eg: "/Articles/Article" in reverse order

Does anyone know a way to do this?


Well if simply loop through the node list from end to beginning e.g.
pseudo code

Dim Articles As XmlNodeList = _
Xml_Document.SelectNodes("/Articles/Article")
For I As Integer = Articles.Count - 1 To 0 Step -1
Console.WriteLine(Articles(I).OuterXml)
Next

you can process the returned node list in reverse order.

XPathExpression and XPathNavigator would allow you to do some sorting if
needed but for the above that is not necessary.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jan 30 '06 #4
A very good resource for XPath functions:

http://www.w3schools.com/xpath/

Sonu Kapoor [MVP]
---
Posted via www.DotNetSlackers.com
Feb 2 '06 #5

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

Similar topics

18
by: comcast | last post by:
Hello all, I am developing an interface system for an application I was written. This interface will connect to other system to share information. I would like to use xml and xsl to generically...
1
by: Xuejun Li \(SH/RDC\) | last post by:
Hi, How do I select a value that starts with a certain prefix? For example I want all <author> elements that contain a <last-name> element with a value that begins with the letter Mi. Will this...
8
by: Terry P | last post by:
Are there any tools (java classes, tag libraries) which can translate xpath statements into a SQL query? Given an xpath query which has a predicate that filters node values or attributes, I want...
7
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
3
by: Paul | last post by:
Does anyone have an idea how to retrieve all nodes in an XmlDocument where the LocalName is equal to some string?
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
3
by: ziggyware | last post by:
Hi All, I have updated my XPath Generator software: XPath Studio .NET. ( http://www.ziggyware.com/downloads.php?cat_id=2 ) Easily select nodes from an xml file to generate XPath statements ...
5
by: kebabkongen | last post by:
Hi, I have an XML source which gives me the start time (in the format hh:mi) of a program and the duration of the program (in minutes). With XSLT only, I would like to generate the time the next...
2
by: arunairs | last post by:
Hi, Is there a way of validating and XPath? In this case , I am accepting an XPath from the user and I need to validate the XPath syntax. Is there a regular expression available that anyone can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...

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.