Code example for Element

Methods: setAttribute, setTextContent

0
            { 
                writeProperty(document, properties, key, value);
            } 
        } 
    } 
 
    private void writeProperty(Document document, Node properties, String key, Object value)
    { 
        Element entry = document.createElement("entry");
        properties.appendChild(entry);
 
        // escape the key 
        String k = StringEscapeUtils.escapeXml(key);
        entry.setAttribute("key", k);
 
        if (value != null)
        { 
            // escape the value 
            String v = StringEscapeUtils.escapeXml(String.valueOf(value));
            v = StringUtils.replace(v, String.valueOf(getListDelimiter()), "\\" + getListDelimiter());
            entry.setTextContent(v);
        }