in reply to Re: Seemingly Valid HTML which crashes HTML::TreeBuilder::XPath
in thread Seemingly Valid HTML which crashes HTML::TreeBuilder::XPath

Thanks.

Would there be a better way of handling the character data (CDATA) found in odd places in the HTML?

What I am trying to do is lift the contents out of an element. Specifically, HTML Tidy adds a body element around any elements and CDATA in a document so,

<body> <p>foo</p> <p>bar</p> </body>

would then after processing become

<p>foo</p> <p>bar</p>

This is so the block which had been body can be inserted into another document, without that new document ending up with multiple body elements. One alternative would have been to change the body to div, but then multiple passes though the work flow would cause multiple, unnecessary, nested div elements. Therefore it seems like the only option is to remove the element completely and leave just its contents.