Answer the question
In order to leave comments, you need to log in
How to select two types of nodes at once in XPath?
I am parsing an HTML DOM document using XPath. There is a task to get a selection at once for two types of nodes located in the hierarchy at the same level. By p and h2 tags . .//div[@class='article']/p
All I've been able to come up with so far is: .//div[@class='article']/p | //h2
But such a query prints all p first , and only then all h2 , which does not solve the problem - it is necessary that the sequence of paragraphs and headings be observed.
What will the community suggest?
Answer the question
In order to leave comments, you need to log in
I guess so. ".//div[@class='article']/p | following-sibling::h2".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question