Convert HTML to XML in PHP

Import HTML content into presentation slides and save the result in PowerPoint XML Presentation format.

Convert HTML to XML using PHP

To convert HTML content to PowerPoint XML, create a Presentation, import the HTML with addFromHtml, and call save with SaveFormat::Xml.

PHP code for converting HTML into XML

$presentation = new Presentation();
try {
    $slides = $presentation->getSlides();
    $slides->removeAt(0);

    $htmlContent = file_get_contents("input.html");
    $slides->addFromHtml($htmlContent);

    $presentation->save("output.xml", SaveFormat::Xml);
} finally {
    $presentation->dispose();
}

Convert HTML to XML in PHP

Aspose.Slides for PHP via Java can import HTML content into presentation slides and save the resulting presentation in PowerPoint XML Presentation format with a few lines of PHP code.

The generated XML represents a presentation rather than a generic transformation of the source HTML markup. Aspose.Slides can also export the imported content to PowerPoint, PDF, images, and other supported formats.

How to convert HTML to XML using Aspose.Slides for PHP API

These are the steps to convert HTML to XML in PHP.

  1. Install Aspose.Slides for PHP via Java.
  2. Configure Aspose.Slides in your PHP project.
  3. Read the HTML content with file_get_contents and pass it to addFromHtml.
  4. Call save with the output file path and SaveFormat::Xml.

Built with Aspose.Slides

Convert HTML to XML Online

The free Aspose.Slides Conversion app is built with Aspose.Slides for PHP via Java, the same API as the code above. Open it and see what the API can do with your own HTML files.

  • Runs in your browser, nothing to install.
  • See how Aspose.Slides converts files before you write code.
  • Upload HTML files and save them as XML.
  • Download the result or convert more files.

Convert HTML To Other Supported Formats

You can also convert HTML and save to other file formats. See all supported formats below: