/**
   * Converts an XML element into an <code>EppCommandRenewXriName</code> object. The caller of this
   * method must make sure that the root node is of an EPP Command Renew entity for EPP XRI I-Name
   * object
   *
   * @param root root node for an <code>EppCommandRenewXriName</code> object in XML format
   * @return an <code>EppCommandRenewXriName</code> object, or null if the node is invalid
   */
  public static EppEntity fromXML(Node root) {
    EppCommandRenewXriName cmd = null;
    String iname = null;
    Calendar curExpDate = null;
    EppPeriod period = null;

    NodeList list = root.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
      Node node = list.item(i);
      String name = node.getLocalName();
      if (name == null) {
        continue;
      }
      if (name.equals("iname")) {
        iname = EppUtil.getText(node);
      } else if (name.equals("curExpDate")) {
        curExpDate = EppUtil.getDate(node, true);
      } else if (name.equals("period")) {
        period = (EppPeriod) EppPeriod.fromXML(node);
      }
    }
    if (iname != null) {
      cmd = new EppCommandRenewXriName(iname, curExpDate, period, null);
    }

    return cmd;
  }
  /**
   * Converts an XML element into an <code>EppResponseDataRenewXriNumber</code> object. The caller
   * of this method must make sure that the root node is the resData element of EPP responseType for
   * creating an EPP XRI I-Number object
   *
   * @param root root node for an <code>EppResponseDataRenewXriNumber</code> object in XML format
   * @return an <code>EppResponseDataRenewXriNumber</code> object, or null if the node is invalid
   */
  public static EppEntity fromXML(Node root) {
    String i_number = null;
    Calendar exDate = null;
    NodeList list = root.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
      Node node = list.item(i);
      String name = node.getLocalName();
      if (name == null) {
        continue;
      } else if (name.equals("inumber")) {
        i_number = EppUtil.getText(node);
      } else if (name.equals("exDate")) {
        exDate = EppUtil.getDate(node);
      }
    }

    return new EppResponseDataRenewXriNumber(i_number, exDate);
  }
  /**
   * Converts an <code>EppResponseDataRenewXriNumber</code> object into an XML element.
   *
   * @param doc the XML <code>Document</code> object
   * @param tag the tag/element name for the <code>EppResponseDataRenewXriNumber</code> object
   * @return an <code>Element</code> object
   */
  public Element toXML(Document doc, String tag) {
    Element elm;
    Element body = doc.createElement(tag);
    ElementNSImpl data = EppUtil.createElementNS(doc, "xriINU", "renData");
    body.appendChild(data);

    if (inumber != null) {
      elm = doc.createElement("inumber");
      elm.appendChild(doc.createTextNode(inumber));
      data.appendChild(elm);
    }
    if (exDate != null) {
      elm = doc.createElement("exDate");
      elm.appendChild(EppUtil.createTextNode(doc, exDate));
      data.appendChild(elm);
    }

    return body;
  }
  /**
   * Converts the <code>EppCommandRenewXriName</code> object into an XML element
   *
   * @param doc the XML <code>Document</code> object
   * @param tag the tag/element name for the <code>EppCommandRenewXriName</code> object
   * @return an <code>Element</code> object
   */
  public Element toXML(Document doc, String tag) {
    Element elm;
    Element body = EppUtil.createElementNS(doc, "xriINA", tag);

    if (iname != null) {
      elm = doc.createElement("iname");
      elm.appendChild(doc.createTextNode(iname));
      body.appendChild(elm);
    }
    if (curExpDate != null) {
      elm = doc.createElement("curExpDate");
      elm.appendChild(EppUtil.createTextNode(doc, curExpDate, true));
      body.appendChild(elm);
    }
    if (period != null) {
      body.appendChild(period.toXML(doc, "period"));
    }

    return toXMLCommon(doc, tag, body);
  }