Hi all,
I am a little fuzzy on those axis predicates in xpath.
I have the following xml:
<root>
<x><title>Title 1</title></x>
<x><sub>item 1</sub></x>
<x><sub>item 2</sub></x>
<x><sub>item 3</sub></x>
<x><sub>item 4</sub></x>
<x><title>Title 2</title></x>
<x><sub>item 5</sub></x>
<x><sub>item 6</sub></x>
<x><title>Title 3</title></x>
<x><sub>item 7</sub></x>
<x><sub>item 8</sub></x>
<x><sub>item 9</sub></x>
</root>
From item 1-4 I want to get Title 1, from item 5-6 I want Title 2, and from
item 7-9 I want Title 3
I am trying to get an XPath from a given x element with a sub child and I
want the first preceding-sibling with a title child. Sometimes I get an xml
with only sub childs (no title elements), so I also need to test whether
such a preceding-sibling exists.
From a given x element I need something preceding-sibling::x
If I only wanted first x-element, counting backwards, I would just put in a
[1].
Now I want the first preceding-sibling::x/title counting backwards, but I am
very unsure of the syntax here:
preceding-sibling::x[title][1]
preceding-sibling::x/title[1]
(preceding-sibling::x/title)[1]
The second solution is the one I think is closest, but I imagine that it
will take the first title element under all the preceding-sibling::x that
has a title child element.
Am I wrong here?
Thank you!
Ragulf Pickaxe
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
--~------------------------------------------------------------------
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>
--~--