Sample code for 30+ languages & platforms
Java

Decode HTML Entities found in XML

Demonstrates how to decode HTML entities found in XML.

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;

    //  Load an XML file containing the following:

    //  <?xml version="1.0" encoding="UTF-8"?>
    //  <output>Franz&#xf6;sische</output> 

    CkXml xml = new CkXml();
    success = xml.LoadXmlFile("qa_data/xml/hasHtmlEntity.xml");

    //  Get non-decoded content, then get decoded content.

    //  Result is Franz&#xf6;sische
    System.out.println(xml.content());

    //  Result is Französische
    String strDecoded = xml.decodeEntities(xml.content());
    System.out.println(strDecoded);
  }
}