3 my $parser = XML
::LibXML
->new;
5 ## Parsing large CDATA sections is very slow, so replace each
6 ## CDATA section with a placeholder tag before parsing the document.
10 $xml =~ s
{<!\
[CDATA\
[((?
>[^\
]]+))\
]\
]>}
16 my $doc = eval { $parser->parse_string($xml) };
19 $@
=~ s/ at \S+ line \d+$//;
24 my $root_node = $doc->getDocumentElement;
26 ## Replace the cdata placeholder tag with a CDATASection node.
27 for my $cdata_node ($root_node->getElementsByTagName('cdata'))
29 $cdata_node->replaceNode(XML
::LibXML
::CDATASection
->new(shift @cdata));