xslt and xpath: match preceding comments

Posted by miasbeck on Stack Overflow See other posts from Stack Overflow or by miasbeck
Published on 2010-04-10T11:15:06Z Indexed on 2010/04/10 11:23 UTC
Read the original article Hit count: 181

Filed under:
|

given this xml:

<root>
    <list>
        <!-- foo's comment -->
        <item name="foo" />
        <item name="bar" />
        <!-- another foo's comment -->
        <item name="another foo" />
    </list>
</root>

I'd like to use a XPath to select all item-nodes that have a comment immediately preceding them, that is I like to select the "foo" and "another foo" items, but not the "bar" item.

I already fiddled about the preceding-sibling axis and the comment() function but to no avail.

© Stack Overflow or respective owner

Related posts about xslt

Related posts about xpath