code: private static void updateNode(Element parent, String nodeName, String value, boolean cdata) {
  
          // get current node element
          Element nodeElement = parent.element(nodeName);
          if (value != null) {
              if (nodeElement == null) {
                  // element wasn't there before, add element and set value
                  nodeElement = parent.addElement(nodeName);
              }
              // element is there, update element value
              nodeElement.clearContent();
              if (cdata) {
                  nodeElement.addCDATA(value);
              } else {
                  nodeElement.addText(value);
              }
          } else {
              // remove only if element exists
              if (nodeElement != null) {
                  // remove element
                  parent.remove(nodeElement);
              }
          }
      }
docs: Updates the given xml node with the given value.<p>
  
  @param parent the parent node
  @param nodeName the node to update
  @param value the value to use to update the given node, can be <code>null</code>
  @param cdata if the value should be in a CDATA section or not