Sample code for 30+ languages & platforms
Java

Convert HTML File to XML File

See more HTML-to-XML/Text Examples

Convert HTML file to XML file.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

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

    CkHtmlToXml htmlToXml = new CkHtmlToXml();

    // Indicate the charset of the output XML we'll want.
    htmlToXml.put_XmlCharset("utf-8");

    success = htmlToXml.ConvertFile("test.html","out.xml");
    if (success != true) {
        System.out.println(htmlToXml.lastErrorText());
        }
    else {
        System.out.println("Success");
        }
  }
}