Sample code for 30+ languages & platforms
Perl

Convert HTML File to XML File

See more HTML-to-XML/Text Examples

Convert HTML file to XML file.

Chilkat Perl Downloads

Perl
use strict;
use warnings;
use Chilkat2;

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

my $htmlToXml = Chilkat2::HtmlToXml->new;

# Indicate the charset of the output XML we'll want.
$htmlToXml->XmlCharset('utf-8');

my $success = $htmlToXml->ConvertFile('test.html', 'out.xml');
if (!$success) {
    print $htmlToXml->LastErrorText, "\n";
} else {
    print "Success\n";
}