/*================================================================
*   ixmlNode_getElementsByTagNameNS
*       Returns a nodeList of all the descendant Elements with a given
*       local name and namespace URI in the order in which they are
*       encountered in a preorder traversal of this Elememt tree.		
*		External function.
*
*=================================================================*/
void
ixmlNode_getElementsByTagNameNS( IN IXML_Node * n,
                                 IN char *namespaceURI,
                                 IN char *localName,
                                 OUT IXML_NodeList ** list )
{
    DOMString nsURI;
    DOMString name;

    assert( n != NULL && namespaceURI != NULL && localName != NULL );

    if( ixmlNode_getNodeType( n ) == eELEMENT_NODE ) {
        name = ixmlNode_getLocalName( n );
        nsURI = ixmlNode_getNamespaceURI( n );

        if( ( name != NULL ) && ( nsURI != NULL ) &&
            ( strcmp( namespaceURI, nsURI ) == 0
              || strcmp( namespaceURI, "*" ) == 0 )
            && ( strcmp( name, localName ) == 0
                 || strcmp( localName, "*" ) == 0 ) ) {
            ixmlNodeList_addToNodeList( list, n );
        }
    }

    ixmlNode_getElementsByTagNameNSRecursive( ixmlNode_getFirstChild( n ),
                                              namespaceURI, localName,
                                              list );

}
/*================================================================
*   ixmlNode_getChildNodes
*       Returns a IXML_NodeList of all the child nodes of nodeptr.
*       External function.
*   
*=================================================================*/
IXML_NodeList *
ixmlNode_getChildNodes( IN IXML_Node * nodeptr )
{
    IXML_Node *tempNode;
    IXML_NodeList *newNodeList;
    int rc;

    if( nodeptr == NULL ) {
        return NULL;
    }

    newNodeList = ( IXML_NodeList * ) ixml_malloc( sizeof( IXML_NodeList ) );
    if( newNodeList == NULL ) {
        return NULL;
    }

    ixmlNodeList_init( newNodeList );

    tempNode = nodeptr->firstChild;
    while( tempNode != NULL ) {
        rc = ixmlNodeList_addToNodeList( &newNodeList, tempNode );
        if( rc != IXML_SUCCESS ) {
            ixmlNodeList_free( newNodeList );
            return NULL;
        }

        tempNode = tempNode->nextSibling;
    }
    return newNodeList;
}
Exemplo n.º 3
0
Arquivo: node.c Projeto: rxwen/pupnp
/*!
 * \brief
 */
static void ixmlNode_getElementsByTagNameNSRecursive(
    /*! [in] . */
    IXML_Node *n,
    /*! [in] . */
    const char *namespaceURI,
    /*! [in] . */
    const char *localName,
    /*! [out] . */
    IXML_NodeList **list)
{
    const DOMString nsURI;
    const DOMString name;

    if (n != NULL) {
        if (ixmlNode_getNodeType(n) == eELEMENT_NODE) {
            name = ixmlNode_getLocalName(n);
            nsURI = ixmlNode_getNamespaceURI(n);

            if (name != NULL && nsURI != NULL &&
                    (strcmp(namespaceURI, nsURI) == 0 ||
                     strcmp(namespaceURI, "*") == 0 ) &&
                    (strcmp(name, localName) == 0 ||
                     strcmp(localName, "*") == 0)) {
                ixmlNodeList_addToNodeList(list, n);
            }
        }
        ixmlNode_getElementsByTagNameNSRecursive(
            ixmlNode_getFirstChild(n), namespaceURI, localName, list);
        ixmlNode_getElementsByTagNameNSRecursive(
            ixmlNode_getNextSibling(n), namespaceURI, localName, list);
    }
}
Exemplo n.º 4
0
Arquivo: node.c Projeto: rxwen/pupnp
void ixmlNode_getElementsByTagName(
    IXML_Node *n,
    const char *tagname,
    IXML_NodeList **list)
{
    const char *name;

    assert(n != NULL && tagname != NULL);

    if (ixmlNode_getNodeType(n) == eELEMENT_NODE) {
        name = ixmlNode_getNodeName(n);
        if (strcmp(tagname, name) == 0 || strcmp(tagname, "*") == 0) {
            ixmlNodeList_addToNodeList(list, n);
        }
    }
    ixmlNode_getElementsByTagNameRecursive(ixmlNode_getFirstChild(n), tagname, list);
}
Exemplo n.º 5
0
Arquivo: node.c Projeto: rxwen/pupnp
/*!
 * \brief Recursively traverse the whole tree, search for element with the
 * given tagname.
 */
static void ixmlNode_getElementsByTagNameRecursive(
    /*! [in] The \b Node tree. */
    IXML_Node *n,
    /*! [in] The tag name to match. */
    const char *tagname,
    /*! [out] The output \b NodeList. */
    IXML_NodeList **list)
{
    const char *name;

    if (n != NULL) {
        if (ixmlNode_getNodeType(n) == eELEMENT_NODE) {
            name = ixmlNode_getNodeName(n);
            if (strcmp(tagname, name) == 0 || strcmp(tagname, "*") == 0) {
                ixmlNodeList_addToNodeList(list, n);
            }
        }
        ixmlNode_getElementsByTagNameRecursive(ixmlNode_getFirstChild(n), tagname, list);
        ixmlNode_getElementsByTagNameRecursive(ixmlNode_getNextSibling(n), tagname, list);
    }
}
/*================================================================
*   ixmlNode_getElementsByTagNameRecursive
*       Recursively traverse the whole tree, search for element
*       with the given tagname.
*       Internal to parser.
*
*=================================================================*/
void
ixmlNode_getElementsByTagNameRecursive( IN IXML_Node * n,
                                        IN char *tagname,
                                        OUT IXML_NodeList ** list )
{
    const char *name;

    if( n != NULL ) {
        if( ixmlNode_getNodeType( n ) == eELEMENT_NODE ) {
            name = ixmlNode_getNodeName( n );
            if( strcmp( tagname, name ) == 0
                || strcmp( tagname, "*" ) == 0 ) {
                ixmlNodeList_addToNodeList( list, n );
            }
        }

        ixmlNode_getElementsByTagNameRecursive( ixmlNode_getFirstChild
                                                ( n ), tagname, list );
        ixmlNode_getElementsByTagNameRecursive( ixmlNode_getNextSibling
                                                ( n ), tagname, list );
    }

}