ANSC_HANDLE
AnscXmlDomNodeGetChildByName
    (
        ANSC_HANDLE                 hThisObject,
        char*                       name
    )
{
    ANSC_STATUS                     returnStatus  = ANSC_STATUS_SUCCESS;
    PANSC_XML_DOM_NODE_OBJECT       pXmlNode      = (PANSC_XML_DOM_NODE_OBJECT)hThisObject;
    PANSC_XML_DOM_NODE_OBJECT       pChildNode    = NULL;

    while ( pChildNode =
                (PANSC_XML_DOM_NODE_OBJECT)AnscXmlDomNodeGetNextChild
                    (
                        (ANSC_HANDLE)pXmlNode,
                        (ANSC_HANDLE)pChildNode
                    ) )
    {
        if ( AnscEqualString(AnscXmlDomNodeGetName((ANSC_HANDLE)pChildNode), name, FALSE) )
        {
            return  (ANSC_HANDLE)pChildNode;
        }
    }

    return  (ANSC_HANDLE)NULL;
}
/**********************************************************************

    prototype:

        ANSC_HANDLE
        CcspCwmpSoappoUtilFindChildNode
            (
                ANSC_HANDLE                 hXmlNode,
                PCHAR                       pInputName
            );

    description:

        This function is called to find the child node with the
        specified node name (ignore namespace);

    argument:
                ANSC_HANDLE                 hXmlNode
                The xml node;

                PCHAR                       pInputName
                The input node name;

    return:     the node found;

**********************************************************************/
ANSC_HANDLE
CcspCwmpSoappoUtilFindChildNode
    (
        ANSC_HANDLE                 hXmlNode,
        PCHAR                       pInputName
    )
{
    PANSC_XML_DOM_NODE_OBJECT       pTempNode       = (PANSC_XML_DOM_NODE_OBJECT)hXmlNode;
    PANSC_XML_DOM_NODE_OBJECT       pChildNode      = (PANSC_XML_DOM_NODE_OBJECT)NULL;
    PCHAR                           pNodeName       = NULL;

    pChildNode = (PANSC_XML_DOM_NODE_OBJECT)
		AnscXmlDomNodeGetHeadChild(pTempNode);

    while(pChildNode != NULL)
    {
        pNodeName =
            CcspCwmpSoappoUtilGetNodeNameWithoutNS
                (
                	AnscXmlDomNodeGetName(pChildNode)
                );

        if( pNodeName != NULL && AnscEqualString(pNodeName, pInputName, TRUE))
        {
            return pChildNode;
        }

        pChildNode = (PANSC_XML_DOM_NODE_OBJECT)
			AnscXmlDomNodeGetNextChild(pTempNode, pChildNode);
    }

    return NULL;
}
ANSC_HANDLE
AnscXmlDomNodeCopy
    (
        ANSC_HANDLE                 hNode
    )
{
    CHAR                            pNodeName[128]  = { 0 };
    ULONG                           uNodeLength     = 128;

    PANSC_XML_DOM_NODE_OBJECT       pOld            = (PANSC_XML_DOM_NODE_OBJECT)hNode;
    PANSC_XML_DOM_NODE_OBJECT       pCopy           = NULL;

    PANSC_XML_ATTRIBUTE             pFirst          = NULL;
    PANSC_XML_ATTRIBUTE             pNewAttribute   = NULL;

    PANSC_XML_DOM_NODE_OBJECT       pFirstNode      = NULL;
    ANSC_HANDLE                     hCopy, hChild;

    if( hNode == NULL)
    {
        return (ANSC_HANDLE)NULL;
    }

    /* create a new node with the node name */
    pCopy = (PANSC_XML_DOM_NODE_OBJECT)AnscXmlDomNodeCreate(pOld->hOwnerContext);
    if( pCopy == NULL)
    {
        return (ANSC_HANDLE)NULL;
    }

    hCopy = (ANSC_HANDLE)pCopy;

    AnscXmlDomNodeSetName(hCopy, AnscXmlDomNodeGetName(hNode));

    /* copy all the attributes */
    pFirst = (PANSC_XML_ATTRIBUTE)AnscXmlDomNodeGetFirstAttr(hNode);
    while ( pFirst != NULL)
    {
        /*
         * generate a new tree Attribute
         */
        pNewAttribute = (PANSC_XML_ATTRIBUTE)AnscAllocateMemory(sizeof(ANSC_XML_ATTRIBUTE));

        if ( !pNewAttribute )
        {
        	AnscXmlDomNodeRemove( hCopy );
            ANSC_XML_TRACE("Failed to allocate attribute structure for in ALXMLCopyHandle\n");

            return (ANSC_HANDLE)NULL;
        }

        AnscZeroMemory(pNewAttribute, sizeof(ANSC_XML_ATTRIBUTE));
        pNewAttribute->hParentNode   = (ANSC_HANDLE)pCopy;
        pNewAttribute->hXMLContext   = pCopy->hXMLContext;
        pNewAttribute->DataSize      = pFirst->DataSize;
        pNewAttribute->StringData    = AnscAllocateMemory( pFirst->DataSize + 1);

        if( pNewAttribute->StringData != NULL)
        {
            AnscZeroMemory(pNewAttribute->StringData,pFirst->DataSize + 1);

            /* copy the attribute name and value */
            AnscCopyString(pNewAttribute->Name, pFirst->Name);

            if( pFirst->StringData != NULL)
            {
                AnscCopyMemory(pNewAttribute->StringData, pFirst->StringData, pNewAttribute->DataSize);
            }

            /* add the attribute to the list */
            AnscAcquireXmlLock(&pCopy->AttributesListLock);
            AnscQueuePushEntry(&pCopy->AttributesList, &pNewAttribute->Linkage);
            AnscReleaseXmlLock(&pCopy->AttributesListLock);
        }
        else
        {
            AnscFreeMemory(pNewAttribute);
        }

        /* goto next attribute */
        pFirst = (PANSC_XML_ATTRIBUTE)AnscXmlDomNodeGetNextAttr(hNode, (ANSC_HANDLE)pFirst);
    }

     /* copy the text value */
    if( pOld->DataSize > 0 && pOld->StringData != NULL)
    {
        pCopy->DataSize   = pOld->DataSize;
        pCopy->StringData = AnscAllocateMemory( pOld->DataSize + 1);

        if( pCopy->StringData != NULL)
        {
            AnscZeroMemory(pCopy->StringData, pOld->DataSize + 1);
            AnscCopyMemory(pCopy->StringData, pOld->StringData, pOld->DataSize);
        }
        else
        {
            pCopy->DataSize = 0;
        }
    }

    /* create and copy all the child node */
    pFirstNode  = AnscXmlDomNodeGetHeadChild(hNode);

    while( pFirstNode )
    {
        hChild  = AnscXmlDomNodeCopy((ANSC_HANDLE)pFirstNode);
        if (hChild)
        	AnscXmlDomNodeAddChild(hCopy, hChild);

        /* goto the next node */
        pFirstNode = AnscXmlDomNodeGetNextChild(hNode, (ANSC_HANDLE)pFirstNode);
    }

    return hCopy;
}