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

xpath expression to return the following node

I want to return with only one xpath expression the first following
node relative to a node with a XPTO attribute.

Example:

<node>
xxx
</node>
<node XPTO="true">
yyy
</node>
<node>
zzz
</node>

i want to return a reference to the node:

<node>
zzz
</node>
thanks in advance
ricky
Jul 20 '05 #1
3 3458
ricky wrote:
I want to return with only one xpath expression the first following
node relative to a node with a XPTO attribute.

Example:

<node>
xxx
</node>
<node XPTO="true">
yyy
</node>
<node>
zzz
</node>

i want to return a reference to the node:

<node>
zzz
</node>
thanks in advance
ricky


hi,

try this :
//node[preceding::node[@XPTO]][1]

what would you expect if there were several nodes with the XPTO attribute ?
--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
Jul 20 '05 #2


ricky wrote:
I want to return with only one xpath expression the first following
node relative to a node with a XPTO attribute.

Example:

<node>
xxx
</node>
<node XPTO="true">
yyy
</node>
<node>
zzz
</node>

i want to return a reference to the node:

<node>
zzz
</node>


This XPath
//node[@XPTO = 'true']/following-sibling::*[1]
finds the first sibling element node.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3
Martin Honnen <ma*******@yahoo.de> wrote in message news:<40********@olaf.komtel.net>...
ricky wrote:
I want to return with only one xpath expression the first following
node relative to a node with a XPTO attribute.

Example:

<node>
xxx
</node>
<node XPTO="true">
yyy
</node>
<node>
zzz
</node>

i want to return a reference to the node:

<node>
zzz
</node>


This XPath
//node[@XPTO = 'true']/following-sibling::*[1]
finds the first sibling element node.


Thanks a lot.
Works perfectly.
I thought that the use of axis were only permitted in the begining of
xpath expression. Need to read more Xpath specification :)

Ricky
Jul 20 '05 #4

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
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";...
13
by: David Thielen | last post by:
XPathNavigator nav = MyCreateNav(); // InnerXml == "software" nav.SelectSingleNode"."); The select returns an exception: + $exception {"'.' has an invalid token."} System.Exception...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
3
by: Goran Djuranovic | last post by:
Hi All, Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer>...
5
by: Gnic | last post by:
Hi , I have an XmlDocument instance, I want to find a node in the xml, but I don't know it's path until runtime, for example <aaa> <bbb name="x"/> <aaa attr="y"> <ccc>sometext</ccc> </aaa>
3
by: Bloody Viking | last post by:
Namaste, Y'all! I've got a valid XQuery expression that I need to convert to XPath 2.0. This expression will be stored in a resource file and applied to XML by a Java program with saxon8.jar...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
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...
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.