Re: [xml] XPath query failing on modified xmlDoc

Cory Virok wrote:
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.

  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.


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,
                    BAD_CAST "user",
    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>

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.

 - Cory Virok

xml mailing list, project page
xml gnome org
Sorry... before I get chewed out, the line reading "xmlNewChild(retPtr, NULL, BAD_CAST "user-cert", xmlCharStrdup(certSubject));" does in fact use "cert-subject".

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