Simple HTML DOM find multiple tags simultaneously

657 views Asked by At

I have a string:

<h2>header 1</h2>
<p>paragraph 1</p>
<h2>header 2</h2>
<h3>siausjfks</h3>
....(anything not containing h2 and p tags)

<div><h2>header 3</h2> jasgfks</div>
.... (anything not containing h2 and p tags)
<p>paragraph 2</p>

Now i want to have array

element 1 = header 1
element 2 = paragraph 1
element 3 = header 2
element 4 = header 3
element 5 = paragraph 2

Is there a way to accomplish this using simple HTML DOM?

Thanks :)

UPDATE: This is actually to find 2 tags simultaneously, how about finding 3, 4 and more tags?

0

There are 0 answers