473,657 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(s trXmlFeedUrl)
Dim xmlDoc = New XmlDocument
xmlDoc.Load(rea der)
Dim urlArticleNodes As XmlNodeList =
xmlDoc.SelectNo des("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 3802


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.Se lectNodes("/Articles/Article")
For I As Integer = Articles.Count - 1 To 0 Step -1
Console.WriteLi ne(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
2750
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 describe each interface. The trouble I am having is that it seem that if you export in xml by table then it is impossible to combine the xml tables files back together in a hierarchical fashion. I can do it programmatically but I would like to...
1
4206
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 work? Or it will also match "Ni"? author A more general question, how do a match against a regular expression? Thanks Li Xuejun
8
7579
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 help constructing the Where clause of a SQL statement that will mirror the expressions and functions contained in the predicate. Such a tool may require an XML to DB mapping or it would need to make assumptions about the structure of the...
7
1805
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"; XmlElement crsElement = (XmlElement)m_colorRangeSwatchDoc.SelectSingleNode(expr); bool fr = bool.Parse(crsElement.GetAttribute("fixed").ToString()); The element returned is always the 1st, All Blue Colors, why doesn't the expression...
3
2322
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
2412
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 stylesheets, that generates .NET assemblies) 2. Performance improvements in the XslCompiledTransform
3
3245
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 Insert node values to narrow down XPath results
5
3583
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 program starts. Ex: If the current program starts at 10:30 and lasts for 60 minutes, I wish to display that the next program starts at 11:30. The server seems to be running XSL 1.0.
2
4714
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 direct me to, to validate a XPath? thanks, Arun
0
8306
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
8732
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...
1
8503
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
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
7327
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
6164
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
5632
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1615
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.