Sample code for 30+ languages & platforms
PHP

Convert HTML File to XML File

See more HTML-to-XML/Text Examples

Convert HTML file to XML file.

Chilkat PHP Downloads

PHP
<?php

use Chilkat2\HtmlToXml;

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

$htmlToXml = new HtmlToXml();

// Indicate the charset of the output XML we'll want.
$htmlToXml->XmlCharset = 'utf-8';

try {
    $htmlToXml->ConvertFile('test.html', 'out.xml');
    echo "Success\n";
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
}