H
H
helixly2016-01-04 21:08:30
PHP
helixly, 2016-01-04 21:08:30

XPath query with no children?

<div class="some-class">
   <div>
        <span>Возраст</span>
        "24"
        <span>лет</span>
   </div>  
</div>

nodeValue after request "//div[contains(@class, 'some-class')]/div"contains (string) "Age 24".
How to exclude children in a query to get 24 right away? <span>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2016-01-04
@helixly

If the html structure is the same, then this option will work
But such an option
will select all text elements, excluding spaces. In your particular case, item(0)->nodeValue will have a value between two spans. If you need all the text element inside the div, then just foreach through the results.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question