Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Seemingly Valid HTML which crashes HTML::TreeBuilder::XPath

by mldvx4 (Friar)
on Nov 10, 2023 at 11:38 UTC ( [id://11155541] : note . print w/replies, xml ) Need Help??


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.