Select the nth child in xQuery / select the next item

I am having trouble finding good xQuery tutorials, basically what I am trying to do is get the text etc...from this html node

<div class="venue">
    <div class="vitem">
        <p style="padding: 6px 0pt 0pt;" class="label">ADDRESS:</p>
        <p class="item-big">blabla</p>
    </div><br class="clear">
    <div class="vitem">
        <p style="padding: 6px 0pt 0pt;" class="label">PHONE:</p>
        <p class="item-big">123</p>
    </div><br class="clear">
    <div class="vitem">
        <p style="padding: 6px 0pt 0pt;" class="label">WEB:</p>
        <p class="item-big">etc...</p>
    </div><br class="clear">
</div>

I would like to know how I can get data from the second p in the third div[@class="vitem"]
Or p immediately after p[@class="label"]that contains the textWEB:

Edit: The answers have already helped, but my second question is that the layout will change to something like this

<div class="venue">
    <div class="vitem">
        <p style="padding: 6px 0pt 0pt;" class="label">ADDRESS:</p>
        <p class="item-big">blabla</p>
    </div><br class="clear">
    <div class="vitem">
        <p style="padding: 6px 0pt 0pt;" class="label">WEB:</p>
        <p class="item-big">etc...</p>
    </div><br class="clear">
</div>

How to get etc..., knowing only that it follows p with a class label containing text WEB:? it is no longer in div [3] / p [2]

Thank!

+3
source share
2 answers

, p [@ class= "vitem" ]

/*/div[@class='vitem'][3]/p[2]/text()

: node p div, class "vitem" .

p p [@ class= "label" ] WEB:

/*/div[@class='vitem'][3]/p[@class='label']
                             /following-sibling::p[1]/text()

: node p p class "label", div, class "vitem" .

UPDATE. OP : p, "etc..."

/*/div/p[.='etc...']
+3

, p div[@class="vitem"] p p[@class="label"]

XPath/XQuery:

/div
   /div[@class='vitem'][3]
      /p[2]

/div
   /div[@class='vitem'][3]
      /p[@class='label']
         /following-sibling::p[1]
+1

Source: https://habr.com/ru/post/1780824/


All Articles