Convert HTML to XML in Java
High-speed and cross-platform Java Library that helps in developing applications with the ability to create, merge, inspect, or convert Microsoft PowerPoint and OpenOffice presentation files without the use of any software like Microsoft or Open Office, Adobe PDF.
Convert HTML to XML in Java
Aspose.Slides for Java is a powerful Java library for creating and manipulating presentation files. Moreover, it provides flexible ways to convert HTML to XML. Using Aspose.Slides for Java, any developer or application can convert HTML to XML files with just a few lines of Java code.
As a modern document processing API, Aspose.Slides for Java exports HTML files to XML file formats quickly. Aspose PowerPoint library allows you to convert HTML to XMLs and many other file formats
Convert HTML to XML using Java
To convert the HTML to XML, you will need to create Presentation from HTML file and save it as XML.
Java code for converting HTML into XML
Presentation pres = new Presentation();
try {
TextReader tr = new StreamReader("file.html");
pres.getSlides().addFromHtml(tr);
for (int index = 0; index < pres.getSlides().size(); index++)
{
ISlide slide = pres.getSlides().get_Item(index);
FileOutputStream fileStream = new FileOutputStream("slide-" + index + ".xml");
try {
slide.writeAsSvg(fileStream);
} finally {
fileStream.close();
}
}
} finally {
if (pres != null) pres.dispose();
}
How to convert HTML to XML using Aspose.Slides for Java API
These are the steps to convert HTML to XML in Java.
Install Aspose.Slides for Java .
Add a library reference (import the library) to your Java project.
Open the source HTML files in Java.
Save result as XML file.
Free Online Converter
Convert HTML To Other Supported Formats
You can also convert HTML and save to other file formats. See all supported formats below