Logo Search packages:      
Sourcecode: libupnp4 version File versions  Download package

EXPORT_SPEC int ixmlDocument_createElementEx ( IXML_Document doc,
const DOMString  tagName,
IXML_Element **  rtElement 
)

Creates a new Element node with the given tag name.

The new Element node has a nodeName of tagName and the localName, prefix, and namespaceURI set to NULL. To create an Element with a namespace, see ixmlDocument_createElementNS.

The ixmlDocument_createElementEx API differs from the ixmlDocument_createElement API in that it returns an error code describing the reason for failure rather than just NULL.

Returns:
An integer representing one of the following:
  • IXML_SUCCESS: The operation completed successfully.
  • IXML_INVALID_PARAMETER: Either doc or tagName is NULL.
  • IXML_INSUFFICIENT_MEMORY: Not enough free memory exists to complete this operation.
Parameters:
doc  [in] The owner Document of the new node.
tagName  [in] The tag name of the new Element node.
rtElement  [out] Pointer to an Element where the new object will be stored.

Definition at line 115 of file document.c.

References ixmlElement_free(), ixmlElement_init(), _IXML_Element::n, _IXML_Node::nodeName, _IXML_Node::nodeType, _IXML_Node::ownerDocument, and _IXML_Element::tagName.

Referenced by ixmlDocument_createElement(), ixmlDocument_createElementNSEx(), and Parser_processElementName().

{
      int errCode = IXML_SUCCESS;
      IXML_Element *newElement = NULL;

      if (doc == NULL || tagName == NULL) {
            errCode = IXML_INVALID_PARAMETER;
            goto ErrorHandler;
      }

      newElement = (IXML_Element *) malloc(sizeof(IXML_Element));
      if (newElement == NULL) {
            errCode = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
      }

      ixmlElement_init(newElement);
      newElement->tagName = strdup(tagName);
      if (newElement->tagName == NULL) {
            ixmlElement_free(newElement);
            newElement = NULL;
            errCode = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
      }
      // set the node fields 
      newElement->n.nodeType = eELEMENT_NODE;
      newElement->n.nodeName = strdup(tagName);
      if (newElement->n.nodeName == NULL) {
            ixmlElement_free(newElement);
            newElement = NULL;
            errCode = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
      }

      newElement->n.ownerDocument = doc;

ErrorHandler:
      *rtElement = newElement;

      return errCode;
}


Generated by  Doxygen 1.6.0   Back to index