public static void setProperty(Element element, String name, String value) {
        if (name == null || name.isEmpty()) return;
        if (value == null) value = "";

        String[] propName = parsePropertyName(name);

        // Search for this property by traversing down the XML hierarchy.
        int i = propName[0].equals(element.getName()) ? 1 : 0;
        for (; i < propName.length - 1; i++) {
            // If we don't find this part of the property in the XML hierarchy
            // we add it as a new node
            if (element.element(propName[i]) == null) {
                element.addElement(propName[i]);
            }
            element = element.element(propName[i]);
        }
        String lastName = propName[propName.length - 1];
        int attributeIndex = lastName.indexOf(':');
        if (attributeIndex >= 0) {
            String eleName = lastName.substring(0, attributeIndex);
            String attName = lastName.substring(attributeIndex + 1);
            // If we don't find this part of the property in the XML hierarchy
            // we add it as a new node
            if (element.element(eleName) == null) {
                element.addElement(eleName);
            }
            element.element(eleName).addAttribute(attName, value);
        }
        else {
            // If we don't find this part of the property in the XML hierarchy
            // we add it as a new node
            if (element.element(lastName) == null) {
                element.addElement(lastName);
            }
            // Set the value of the property in this node.
            element.element(lastName).setText(value);
        }
    }
Sets the value of the specified property. If the property doesn't
currently exist, it will be automatically created.

@param element the element to set the property on
@param name  the name of the property to set.
@param value the new value for the property.
xmppserver/src/main/java/org/jivesoftware/util/ElementUtil.java