Andrey Vorobyev
Andrey Vorobyev

Reputation: 886

Xpath select first level childs

I have document

<ul class="section">
 <li>
 <ul class="section">
  <li><span>world</span></li>
 </ul>
 <span>hello</span>
 </li>
 <li><span>!</span></li>
</ul>

I want to select li on first level, and i have xpath expression:

//ul[@class="section"]/li

But it selects all li.

Upvotes: 3

Views: 1581

Answers (1)

potame
potame

Reputation: 7905

One way to do that can be: ul[@class="section" and not(parent::li)]/li

Upvotes: 3

Related Questions