Convert HTML to XML in Java

Convert HTML files to XML-based output using Aspose.Slides for Java without Microsoft PowerPoint.

Convert HTML to XML in Java

Aspose.Slides for Java is a presentation processing API that can import HTML content and save slide output as XML-based files.

Aspose.Slides for Java can convert HTML content to XML-based output and other presentation-related formats.

Convert HTML to XML using Java

To convert HTML to XML-based output, create a Presentation from the source file and write each slide as an XML-based file.

Java code for converting HTML into XML

Presentation presentation = new Presentation();
try {
    presentation.getSlides().removeAt(0);
    try (FileInputStream htmlStream = new FileInputStream("page.html")) {
        presentation.getSlides().addFromHtml(htmlStream);
    }

    for (int slideIndex = 0; slideIndex < presentation.getSlides().size(); slideIndex++) {
        ISlide slide = presentation.getSlides().get_Item(slideIndex);
        try (FileOutputStream fileStream = new FileOutputStream("slide_" + (slideIndex + 1) + ".xml")) {
            slide.writeAsSvg(fileStream);
        }
    }
} finally {
    presentation.dispose();
}

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

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

  1. Install Aspose.Slides for Java .

  2. Add a library reference (import the library) to your Java project.

  3. Load the source HTML file into a Presentation.

  4. Write each ISlide as an XML-based file.

Free Online Converter

Convert presentations and slides online.

Convert HTML To Other Supported Formats

You can also convert HTML and save it to other file formats.