// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.StringReader;

import javax.xml.parsers.DocumentBuilderFactory;

import org.apache.xpath.XPathAPI;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;

public class Esc {
    public static void main(String[] args) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        Document trae = factory.newDocumentBuilder().parse(new InputSource(new StringReader("<all><foobar>&lt;bla bla&gt;</foobar></all>")));
        Node n =  XPathAPI.selectSingleNode(trae, "//all/foobar/text()");
        System.out.print(n.getNodeValue());
    }
}
