Re: [xml] XPath query failing on modified xmlDoc



Daniel Veillard wrote:
On Mon, Aug 09, 2004 at 07:49:12AM -0400, Cory Virok wrote:
  
So either no one understands my question or it's just been ignored. 
Either way I'd like to try posting it again.
Anyone?
    

  There is nothing in your report which could explain why that would
fail. XPath work on a tree. You modify the tree, rerun XPath, that 
should just work unless you made a programming error. So my bet is
it's the second and there is no way I can know what happens, how,
nor do I really have time chasing those issues.
  Since I have nothing to report I did not reply to your email.

Daniel

  
I realize that it *should* work, but the fact of the matter is that it does not and I'm trying to find out why.
If you don't have time to answer this email then please ignore. For all the others, here's the code used to create and insert the new element that is not recognized by the xpath query:

xmlNodePtr Foo::createNewUserNode(xmlNodePtr userParentPtr, char *nickname, char *certSubject, char *firstName, char *lastName) {
   
    // Create the "user" node
    xmlNodePtr retPtr = xmlNewChild(userParentPtr,
                    xmlNewNs(userParentPtr,
                        xmlCharStrdup(NEW_USER_NODE_NS_HREF),
                        xmlCharStrdup(NEW_USER_NODE_NS_PREFIX)),
                    BAD_CAST "user",
                    NULL);
    xmlNewProp(retPtr, BAD CAST "nickname", xmlCharStrdup(nickname));

    xmlNewChild(retPtr, NULL, BAD_CAST "user-cert", xmlCharStrdup(certSubject));
    xmlNewChild(retPtr, NULL, BAD_CAST "first-name", xmlCharStrdup(firstName));
    xmlNewChild(retPtr, NULL, BAD_CAST "last-name", xmlCharStrdup(lastName));

    return retPtr;
}


Here's the xml:

<?xml version="1.0" encoding="UTF-8"?>
<config ...>
    <user-list>   <!-- userParentPtr from above code points here -->
        <user nickname="CV">
            <cert-subject>DN=Cory Virok ...</cert-subject>
            <first-name>Cory</first-name>
            <last-name>Virok</last-name>
        </user>
       ...
    </user-list>
</config>


So after I add in this child I cannot seem to find it via an xpath query. All looks well in the document when I dump it out. And if I save it to a file, then re-parse it, the query finds the previously added node no problem!

Any help is again, appreciated.

Thanks,
 - Cory Virok


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]