473,396 Members | 1,826 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 that gets a node with 2 particular children

I'd like to write an XPath expression that gets a node with 2
particular children.

I thought this would work:
/AAA/BBB/CCC/following-silbing::DDD/parent::node()

on xml like this:

AAA
BBB
CCC
DDD
/BBB
/AAA

But it doesn;t seem to. I've been testing it here:
http://www.zvon.org:9001/saxon/cgi-b...L/source1.html
I would like to have some sort of "/sibling::DDD" so that I can find
any sib not just following or preceeding, but I can't seem to find a
way to do that either.

Any ideas?

BTW, My next step is to also require the that a particular attribute
of one of the children has one of a set of values.

Thanks.
Jul 20 '05 #1
2 2090
> AAA
BBB
CCC
DDD
/BBB
/AAA
This is not xml at all, probably you meant:
<AAA>
<BBB>
<CCC/>
<DDD/>
</BBB>
</AAA>

Use:

/AAA/BBB[CCC and DDD and not(*[3])]


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


"Jeff" <LN****@hotmail.com> wrote in message
news:ce**************************@posting.google.c om... I'd like to write an XPath expression that gets a node with 2
particular children.

I thought this would work:
/AAA/BBB/CCC/following-silbing::DDD/parent::node()

on xml like this:

AAA
BBB
CCC
DDD
/BBB
/AAA

But it doesn;t seem to. I've been testing it here:
http://www.zvon.org:9001/saxon/cgi-b...L/source1.html
I would like to have some sort of "/sibling::DDD" so that I can find
any sib not just following or preceeding, but I can't seem to find a
way to do that either.

Any ideas?

BTW, My next step is to also require the that a particular attribute
of one of the children has one of a set of values.

Thanks.

Jul 20 '05 #2
In case the order of the children matters, then this should be reflected in
the XPath expression:

/AAA/BBB[ *[1][self::CCC] and *[2][self::DDD] and not(*[3]) ]

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Dimitre Novatchev" <dn********@yahoo.com> wrote in message
news:be************@ID-152440.news.dfncis.de...
AAA
BBB
CCC
DDD
/BBB
/AAA


This is not xml at all, probably you meant:
<AAA>
<BBB>
<CCC/>
<DDD/>
</BBB>
</AAA>

Use:

/AAA/BBB[CCC and DDD and not(*[3])]


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


"Jeff" <LN****@hotmail.com> wrote in message
news:ce**************************@posting.google.c om...
I'd like to write an XPath expression that gets a node with 2
particular children.

I thought this would work:
/AAA/BBB/CCC/following-silbing::DDD/parent::node()

on xml like this:

AAA
BBB
CCC
DDD
/BBB
/AAA

But it doesn;t seem to. I've been testing it here:
http://www.zvon.org:9001/saxon/cgi-b...L/source1.html
I would like to have some sort of "/sibling::DDD" so that I can find
any sib not just following or preceeding, but I can't seem to find a
way to do that either.

Any ideas?

BTW, My next step is to also require the that a particular attribute
of one of the children has one of a set of values.

Thanks.


Jul 20 '05 #3

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

Similar topics

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";...
2
by: Steve Jorgensen | last post by:
Working with the DOM (specifically, the MSXML DOM), I'm wondering if there's an efficient way to check whether it would be matched by a given XPath expression. I've made it work to just run the...
1
by: Rob | last post by:
Hi, I am moving through an XML document using an XPath Navigator, and I'd like to be able to get the xpath expression for the location of the current node from the root node. Any ideas how to...
1
by: helpful sql | last post by:
Hi all, Following is a part of an Xml document I am having problems with. I have a XmlNode variable in my C# application that referes to the mytable node of the following Xml. Now I need to get...
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...
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>...
1
by: woodworthjames | last post by:
Hello, not sure i am using xpath correctly. have the following trivial xml. <?:xml version="1.0" standalone="yes" ?> <top attr="1"> content1 content2 <inner id="first" day="friday"> content3...
3
by: Arndt Jonasson | last post by:
Let's say we have a schema (maybe expressed in XML Schema, but not necessarily so), that allows this instance document: <top> <txt>This is text</txt> <books> <book>Tarzan</book> <book>Harry...
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
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: 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
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,...
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
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...
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.