[jdom-interest] problem with & conversion string_to_jdom

frederic Mottais frederic.mottais at cibf.com
Thu Apr 15 02:27:40 PDT 2004


Hello

When I want to convert a string (which is like an xml document) in a document JDOM, I have a problem when there is a &.
Must I need to convert & by & in the string or SAXbuilder can do it? How can i do ?

the exemple
            String toto = "<root><footer>TO&TO</footer></root>";

            SAXBuilder builder = new SAXBuilder();

            Document doc = builder.build(new StringReader(toto));

            Element eltTmp = doc.getRootElement();

            System.out.println(eltTmp.getChildText("footer"));



 

org.jdom.input.JDOMParseException: Error on line 1: La référence à l'entité "TO" doit se terminer par le délimiteur ';'.

      at org.jdom.input.SAXBuilder.build(SAXBuilder.java:466)

      at org.jdom.input.SAXBuilder.build(SAXBuilder.java:849)

      at cibf.test.testDocJdom.main(testDocJdom.java:58)

Caused by: org.xml.sax.SAXParseException: La référence à l'entité "TO" doit se terminer par le délimiteur ';'.

      at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1172)

      at org.jdom.input.SAXBuilder.build(SAXBuilder.java:455)

      at org.jdom.input.SAXBuilder.build(SAXBuilder.java:849)

      at cibf.test.testDocJdom.main(testDocJdom.java:58)



thanks


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20040415/8b40b63c/attachment.htm


More information about the jdom-interest mailing list