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

EXPORT_SPEC int ixmlDocument_createElementNSEx ( IXML_Document doc,
const DOMString  namespaceURI,
const DOMString  qualifiedName,
IXML_Element **  rtElement 
)

Creates a new Element node in the given qualified name and namespace URI.

The ixmlDocument_createElementNSEx API differs from the ixmlDocument_createElementNS 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, namespaceURI, or qualifiedName is NULL.
  • IXML_INSUFFICIENT_MEMORY: Not enough free memory exists to complete this operation.
Parameters:
doc  [in] The owner Document of the new node.
namespaceURI  [in] The namespace URI for the new Element.
qualifiedName  [in] The qualified name of the new Element.
rtElement  [out] A pointer to an Element where the new object will be stored.

Definition at line 440 of file document.c.

References ixmlDocument_createElementEx(), ixmlElement_free(), ixmlNode_setNodeName(), IxmlPrintf(), _IXML_Element::n, _IXML_Node::namespaceURI, and _IXML_Node::nodeValue.

Referenced by ixmlDocument_createElementNS().

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

      if (doc == NULL || namespaceURI == NULL || qualifiedName == NULL) {
            line = __LINE__;
            errCode = IXML_INVALID_PARAMETER;
            goto ErrorHandler;
      }

      errCode = ixmlDocument_createElementEx(doc, qualifiedName, &newElement);
      if (errCode != IXML_SUCCESS) {
            line = __LINE__;
            goto ErrorHandler;
      }
      // set the namespaceURI field 
      newElement->n.namespaceURI = strdup(namespaceURI);
      if (newElement->n.namespaceURI == NULL) {
            line = __LINE__;
            ixmlElement_free(newElement);
            newElement = NULL;
            errCode = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
      }
      // set the localName and prefix 
      errCode = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
      if (errCode != IXML_SUCCESS) {
            line = __LINE__;
            ixmlElement_free(newElement);
            newElement = NULL;
            errCode = IXML_INSUFFICIENT_MEMORY;
            goto ErrorHandler;
      }

      newElement->n.nodeValue = NULL;

ErrorHandler:
      *rtElement = newElement;
      if (errCode != IXML_SUCCESS) {
            IxmlPrintf("(%s::ixmlDocument_createElementNSEx): Error %d, line %d\n",
                  __FILE__, errCode, line);
      }

      return errCode;
}


Generated by  Doxygen 1.6.0   Back to index