Archived Forum Post

Index of archived forum posts

Question:

ConvertFile not work

Jun 27 '13 at 12:09

I tried to convert an html file to an xml file by using the ConvertFile method of the CkHtmlToXml class. However, there is no result.

Here is the Java code i tried: import com.chilkatsoft.CkHtmlToXml;

public class HTMLToXML {

static {
    try{
        System.load("D:/mydoc/JavaEclipse/html-xml/chilkat-9.4.0-jdk6-win32/chilkat.dll");
    }catch(UnsatisfiedLinkError e){e.printStackTrace();}
}
public static void main(String[] args){

    convertHTMLToXML("D:/ImageEditor.html","D:/test/ImageEditor.xml");
}

public static void convertHTMLToXML(String htmlfile, String xmlfile){

    CkHtmlToXml ck=new CkHtmlToXml();
    ck.ConvertFile(htmlfile, xmlfile);

}

}

Thank in advance


Answer

The ConvertFile method returns true for success and false for failure. Make sure your code checks the return value. If it fails, then examine the contents of the LastErrorText:

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