Chris,
Doesn't your problem reduce to the first c node descendant?
/descendant::c[1]
?
Cheers,
Wendell
At 07:08 AM 6/7/2006, you wrote:
Hi everyone,
I have a XPath problem that "should" be reasonably easy to solve,
but so far has just left me scratching my head.
Given the following XML*
<data>
<a>
<b/>
</a>
<a>
<b>
<c/>
<b/>
</a>
<a>
<b/>
<b>
<c/>
<b/>
</a>
</data>
* Note that this is just an example, the structure of the XML I'm
working with changes each time. Having said that, there are always 1
or more "a" nodes, "a" nodes contain "b" nodes and there are always
1 or more "b" nodes, "b" nodes contain "c" nodes and a "c" node is
either present or not present.
I am trying to create an XPath statement that selects the "c" node
child of the first "b" node child (that has a "c" node child) of the
first "a" node (that has a "b" node child, that in turn has a "c"
node child). If that makes any sense :)
Note that I would just like to select 1 "c" node, as opposed to the
set of "c" nodes.
I tried the following statement...
/data/a[1]/b[1]/c
....and while (if it works) it only selects 1 node, it just selects
the first "a" node regardless of whether or not it contains a "b"
node (and regardless of whether or not that "b" node contains a "c"
node). In other words it only works if the first "a" node contains a
"b" and that "b" node contains a "c" node, otherwise it fails.
I've tried so many variations on this statement that I've lost
count, but so far I haven't been able to get it do what it needs to.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--