Code example for Node

Methods: appendChild, getParentNode

0
    public void endElement(String uri, String localName, String rawName)
        throws SAXException { 
        appendStringData(); // add string data if any. 
 
        if (currentNode != null)
            currentNode = currentNode.getParentNode();
        namespaces.pop();
    } 
 
    public void appendStringData() { 
        if (!stringContent) return;
 
        String str = stringBuffer.toString();
        stringBuffer.setLength(0); // reuse buffer.
        stringContent = false;
        if (currentNode == null) {
            if (inCDATA) preInfo.add(new CDataInfo(str));
            else         preInfo.add(new TextInfo(str));
        } else { 
            Node n;
            if (inCDATA) n = document.createCDATASection(str);
            else         n = document.createTextNode(str);
            currentNode.appendChild(n);
        } 
    } 
 
    /** 
     * <b>SAX</b>: Implements {@link