code: public static Element appendElement(Element parent, String tagName) {
          Element child = parent.getOwnerDocument().createElement(tagName);
          parent.appendChild(child);
          return child;
      }
docs: Appends the child element to the parent element.
  
  @param parent the parent element
  @param tagName the child element name
  @return the child element added to the parent element