T
T
Troodi Larson2018-08-21 12:53:23
PHP
Troodi Larson, 2018-08-21 12:53:23

How to parse tags one by one?

There is an xpath like this:

filterXPath('//p|//img|//blockquote|//ul|//li|//strong|//b|//i')

And the problem is there is a block <blockquote>in which and <strong>, and , thereby parsing all the text from three at once.
I.e:
[0] => Текст из цитаты вместе с жирным и параграфом
[1] => Жирный из blockquote
[2] => Параграф из blockquote

Texts are duplicated. But under the quote, there are also paragraph and bold tags, that is, strong and p tags cannot be removed from xpath either. Is it possible to somehow take , which is not in the blockquote?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Fov, 2018-11-23
@troodi

Here or specify exactly what you need (with all sorts of dirty tricks):
XML

<div>
  <p>par</p>
  <strong>strong</strong>
  <divd>
    <p>divpar</p>
  </divd>
  <blockquote>
    <p>bqpar <strong>bqparstrong</strong></p>
  </blockquote>
</div>

XPath
result
Element='<p>par</p>'
Element='<strong>strong</strong>'
Element='<p>divpar</p>'
Element='<blockquote><p>bqpar <strong>bqparstrong</strong></p></blockquote>'

or stop abusing double slashes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question