Code example for Element

Methods: appendChild, setAttribute

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