Answer the question
In order to leave comments, you need to log in
How to get the current element AND its first child using "ancestor-or-self"?
Hello!
There is html (the example is synthetic, the real example is much more complicated, that's why I want to use the "ancestor-or-self" axis):
<body>
<div>
<p id="foo"></p>
<p id="bar"> <- получить этот узел...
<a> <- ...И этот узел
<a>
body/div/p[@id='bar']/node()[descendant-or-self::a[1]]
Answer the question
In order to leave comments, you need to log in
ancestor-or-self, by definition, cannot do this, because will return the entire set of ancestors. But if you need to " get "p#bar" and its first "a" ", then this:
//p[@id="bar"]/a[1] | //p[@id="bar"]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question