I have the following HTML:
<p>This is a tag</p>
<div>Another tag</p>
<div><a href="#">anchor</a><div>
<br>
<br>
<math xmlns="http://www.w3.org/1998/Math/MathML">
    <mi>x</mi>
    <mo>=</mo>
</math>
<hr><br>
I want to extract all HTML and MathML into an array and keep their order:
[
   [0] => '<p>This is a tag</p>
    <div>Another tag</p>
    <div><a href="#">anchor</a><div>
    <br>
    <br>',
   [1] => '<math xmlns="http://www.w3.org/1998/Math/MathML">
        <mi>x</mi>
        <mo>=</mo>
    </math>'
   [2] => '<hr><br>'
]
Can Regex do this, because HR or BR tag could don't have closed splash? Or any library?
Any help will be greatly appreciated. Thanks in advance.
 
    