code: public static void setElementContent(final Node n,
                                         final String s) throws SAXException {
      NodeList children = n.getChildNodes();
  
      for (int i = 0; i < children.getLength(); i++) {
        Node curnode = children.item(i);
  
        n.removeChild(curnode);
      }
  
      Document d = n.getOwnerDocument();
  
      final Node textNode = d.createTextNode(s);
  
      n.appendChild(textNode);
    }
docs: Replace the content for the current element.
  
  @param n element
  @param s string content
  @throws SAXException