HTML-Tidy-libXML

 view release on metacpan or  search on metacpan

lib/HTML/Tidy/libXML.pm  view on Meta::CPAN

    my ($self, $dom, $level) = @_;
    my $root = $dom->findnodes('/html')->shift;
    $root->setAttribute( xmlns => 'http://www.w3.org/1999/xhtml' );
    for my $meta ( $dom->findnodes('//meta[@http-equiv!=""]') ) {
        $meta->setAttribute( content => 'text/html; charset=utf-8' );
    }
    _tidy_dom($dom) if  $level > 0;
    my $xhtml = $root->toString( 0, 'utf-8' );    # utf8 flag off
    return <<EOT;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
$xhtml
EOT
}

sub html2xml {
    my ( $self, $html, $encoding, $level ) = @_;
    my $dom = $self->html2dom( $html, $encoding );
    $self->dom2xml($dom, $level);
}



( run in 0.629 second using v1.01-cache-2.11-cpan-49f99fa48dc )