XPath query : select only node with unique child
I wish to select al开发者_StackOverflow社区l <span> that have only <br> as children :
<html>
..
<span>
...
</span>
<span> <!-- I want those ones -->
<br/>
</span>
How would I select these elements?
Assuming you mean elements with no children except br elements, where br is mandatory:
/html/span
[br and not(
*[not(self::br)]
)]
Meaning: All span elements which have at least one br child and no other elements as children.
加载中,请稍侯......
精彩评论