Code example for Element

Methods: appendChild, setAttribute

0
    } 
 
    public void testTextChild() throws Exception { 
        Document doc = getDocument();
        Element e = doc.createElementNS("urn:test", "root");
        e.setAttribute("xmlns", "urn:test");
        doc.appendChild(e);
        Node text = doc.createTextNode("Hello World");
        e.appendChild(text);
 
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        writeXml(doc, baos);
        LOG.info(baos.toString());
 
        W3CDOMStreamReader reader = new W3CDOMStreamReader(e);
        testTextChild(reader);
    } 
 
    public void testMixedContent() throws Exception { 
        Document doc = getDocument();
        Element e = doc.createElementNS("urn:test", "test:root");