F
F
Formula_12016-08-18 12:12:47
Parsing
Formula_1, 2016-08-18 12:12:47

How to parse content that is between two divs?

Hello, can you please tell me how to parse the content between two divs using the "Php simple html dom parser" parser?
For example, there is such a layout:

<div class="start">Текст</div> <!-- Начало парсинга с этого дива -->
<p>Первый контент</p>
<p>Второй контент</p>
<p>Третий контент</p>
<div class="end">Текст</div> <!-- и до этого дива -->

Tell me how can this be done? Maybe through conditions?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nirvimel, 2016-08-18
@Formula_1

XPath decides:
But if it is not necessary to capture the start / end divs, then the task is greatly simplified:

//*[preceding-sibling::div[@class="start"] and following-sibling::div[@class="end"]]

D
D', 2016-08-18
@Denormalization

preg_match("/<div class="start">.*</div>(.*)<div class="end">.*</div>/Ui", ...)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question