/** * <p> * Append a new element child to the current node * </p> * @param parent is the parent node for the new child element * @param elementName is new element tag name * @return the newly created child node */ public static Element appendChild(Node parent, String elementName) { Element child = getOwnerDocument(parent).createElement(elementName); parent.appendChild(child); return child; }
/** * <p> * Append a new element child to the current node * </p> * @param parent is the parent node for the new child element * @param elementName is new element tag name * @return the newly created child node */ public static Element appendChild(Node parent, String elementName) { Element child = getOwnerDocument(parent).createElement(elementName); parent.appendChild(child); return child; }
/** * <p> * Append a new text child * </p> * @param parent for the new child element * @param elementName is the new element tag name * @param text the text for the new element * @result the newly create child node */ public static Node appendTextChild(Node parent, String elementName, String text) { if (text == null || text.length()==0) return null; Node child = appendChild(parent, elementName); child.appendChild(getOwnerDocument(child).createTextNode(text)); return child; }
/** * <p> * Append a new text child even if text is empty * </p> * @param parent for the new child element * @param elementName is the new element tag name * @param text the text for the new element * @result the newly create child node */ public static Node forceAppendTextChild(Node parent, String elementName, String text) { Node child = appendChild(parent, elementName); if (text != null && text.length()!=0) { child.appendChild(getOwnerDocument(child).createTextNode(text)); } return child; }
/** * <p> * Append a new text child * </p> * @param parent for the new child element * @param elementName is the new element tag name * @param text the text for the new element * @result the newly create child node */ public static Node appendTextChild(Node parent, String elementName, String text) { if (text == null || text.length()==0) return null; Node child = appendChild(parent, elementName); child.appendChild(getOwnerDocument(child).createTextNode(text)); return child; }
/** * <p> * Append a new text child even if text is empty * </p> * @param parent for the new child element * @param elementName is the new element tag name * @param text the text for the new element * @result the newly create child node */ public static Node forceAppendTextChild(Node parent, String elementName, String text) { Node child = appendChild(parent, elementName); if (text != null && text.length()!=0) { child.appendChild(getOwnerDocument(child).createTextNode(text)); } return child; }