July 2011 Archives

XML::LibXML parse_html_string iframe games

Given HTML with certain "empty" tags that you wanted to manipulate via something like:

my $html = '<p><iframe src="..."></iframe></p>';
my $doc = XML::LibXML->new->parse_html_string($html);
# do stuff with $doc

You would end up with:

<p><iframe src="..."/></p>';

Namely, the "empty" iframe tag is going to get output as a single, self-closing tag.

But that's not valid HTML. Not even valid HTML5.


About minty

user-pic I blog about Perl.