Answer the question
In order to leave comments, you need to log in
How to find the following-sibling AND the node itself?
Hello!
<root>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li><div><a>6</a></div></li>
<li>7</li>
<li>8</li>
</root>
li/div/a
AND the node itself from which we start ( li/div/a
)? <li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li><div><a>6</a></div></li>
//li[div/a]/self::node()[self::node() and self::node()/preceding-sibling::li]
Answer the question
In order to leave comments, you need to log in
You have an error in the title of your question. following is after the node. The correct expression would be:
//li[div/a]/(preceding-sibling::li|self::li)
If there is any misunderstanding in this expression, then ask. I can explain at each step of addressing.
There is a desire to understand XPath deeper, then I recommend an introductory video: XPath is strong!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question