Code example for Element

Methods: setTextContent

0
 
    public void testSimple() { 
        Document doc = DOMUtils.newDocument();
        Map<String, Element> m = new HashMap<String, Element>();
        Element element = doc.createElement("part1");
        element.setTextContent("42 3.14159");
        m.put("part1", element);
 
        element = doc.createElement("part2");
        element.setTextContent("hello word @#$% &*");
        m.put("part2", element);
 
        element = doc.createElement("emptyPart");
        m.put("emptyPart", element);
 
        String res = transformer.transform(m);
        assertTrue(res.contains("part1=42+3.14159"));
        assertTrue(res.contains("part2=hello+word+%40%23%24%25+%26*"));
        assertTrue(res.contains("emptyPart="));
        assertTrue(res.split("&").length == m.size());
    }