Exemplo n.º 1
0
/*================================================================
*   ixmlDocument_importNode
*       Imports a node from another document to this document. The
*       returned node has no parent; (parentNode is null). The source
*       node is not altered or removed from the original document;
*       this method creates a new copy of the source node.

*       For all nodes, importing a node creates a node object owned
*       by the importing document, with attribute values identical to
*       the source node's nodeName and nodeType, plus the attributes
*       related to namespaces (prefix, localName, and namespaceURI).
*       As in the cloneNode operation on a node, the source node is
*       not altered.
*
*       External function.
*
*=================================================================*/
int
ixmlDocument_importNode( IN IXML_Document * doc,
                         IN IXML_Node * importNode,
                         IN unsigned char deep,
                         OUT IXML_Node ** rtNode )
{
    unsigned short nodeType;
    IXML_Node *newNode;

    *rtNode = NULL;

    if( ( doc == NULL ) || ( importNode == NULL ) ) {
        return IXML_INVALID_PARAMETER;
    }

    nodeType = ixmlNode_getNodeType( importNode );
    if( nodeType == eDOCUMENT_NODE ) {
        return IXML_NOT_SUPPORTED_ERR;
    }

    newNode = ixmlNode_cloneNode( importNode, deep );
    if( newNode == NULL ) {
        return IXML_FAILED;
    }

    ixmlDocument_setOwnerDocument( doc, newNode );
    *rtNode = newNode;

    return IXML_SUCCESS;
}
Exemplo n.º 2
0
static int s_CD_GetBestRes (char *dms_ip, char *metadata, IXML_Node **best_res)
{
	int ret = -1;
	
	if(!dms_ip || !metadata || !best_res)
		return -2;
	
	IXML_Document *subdoc = ixmlParseBuffer (discard_const_p (char, metadata));
	if(subdoc)
	{
		IXML_NodeList* items =	ixmlDocument_getElementsByTagName (subdoc, "item"); 
		if(items)
		{
			IXML_Node* node = ixmlNodeList_item(items,  0);
			if(node)
			{
				IXML_NodeList* reslist = ixmlElement_getElementsByTagName ((IXML_Element*)node, "res");
				if(reslist)
				{
					IXML_Node* res = s_CD_GetWantedRes(dms_ip, reslist, "http-get","null");
					if(res)
					{
						*best_res = ixmlNode_cloneNode(res, true);
						ret = 0;
					}
					ixmlNodeList_free (reslist);
				}
			}
			ixmlNodeList_free (items);
		}
		ixmlDocument_free(subdoc);
	}
	return ret;
}