I am trying to put in an HTML string after the h1 tag to the next h1 tag, and then continue.
For example, here is the HTML:
<h1>Heading</h1> <p>Paragraph</p> <ul> <li>List item</li> <li>List item</li> </ul> <p>Paragraph</p> <h1>Heading 2</h1> <ul> <li>List item</li> <li>List item</li> </ul> <p>Paragraph<img /></p>
And from this I am trying to create this array:
array( 0 => '<p>Paragraph</p><ul><li>List item</li><li>List item</li></ul><p>Paragraph</p>', 1 => '<ul><li>List item</li><li>List item</li></ul><p>Paragraph<img /></p>' )
What will be the XPath query to select all the content after the h1 tag to the next, etc.?
Any help or advice is appreciated.
UPDATE:
I end up trying to achieve using PHP to create this array format:
array( 'headings' => array( 1 => '<h1>Heading</h1>', 2 => '<h1>Heading 2</h1>' ), 'content' => array( 1 => '<p>Paragraph</p><ul><li>List item</li><li>List item</li></ul><p>Paragraph</p>', 2 => '<ul><li>List item</li><li>List item</li></ul><p>Paragraph<img /></p>' ) )
source share