Hello! How to use xpath to set the path to several specific elements, that is, I have, for example, such code:

<div id="post-body"> <p>p1</p> <p>p2</p> <blockquote><p>blockquote/p1</p></blockquote> <div><p>div/p1</p></div> <blockquote><p>blockquote/p2</p></blockquote> </div> 

I need to pull out:

 p1 p2 blockquote/p1 blockquote/p2 

How to do it?

  • I can offer to pull out elements with post-body // Employee [@ id = 'post-body'] - jashka
  • one
    For example, /div[@id="post-body"]/p/text() | /div[@id="post-body"]/blockquote/p/text() /div[@id="post-body"]/p/text() | /div[@id="post-body"]/blockquote/p/text() - Alex Krass

1 answer 1

Specifically, in this case, the easiest way is to look for child p elements to id = "post-body": id('post-body')/p/text() | id('post-body')//blockquote/p/text() id('post-body')/p/text() | id('post-body')//blockquote/p/text()