Re: [xml] general help with using XPath with libxml2 (fwd)


Check if this attachment helps you



-----Original Message-----
From: Peter Wilkes [mailto:pwilkes cowpie acm vt edu] 
Sent: Tuesday, November 14, 2006 2:20 AM
To: xml gnome org
Subject: [xml] general help with using XPath with libxml2 (fwd)


        i've been asked to convert some XML parsing code that relys on
XPath from the Microsoft XML objects to another platform independent
toolkit.  libxml seems very light weight (which is good for us) and easy
to use.  i have some questions though as i am a newbie to XML/XPath and

1. i have an xmlXPathObjectPtr which points to an array of objects each
containing data X, Y, and Z. i would like to look up the field by name.
ex. Lookup(MyxmlXPathObjectPtr, "field1"); currently i have this solved
by doing a short while loop.

xmlNodePtr nodePtr = nodeSet->nodeTab[pos]; if(nodePtr == NULL) {
        return false;

bool found = false;
xmlNodePtr runner = nodePtr->children;
while( (runner != NULL) && (!found) )
        if(strcmp(element, (char *)runner->name) == 0)
                strncpy(val, (char *)runner->children->content, valLen);
                found = true;
        runner = runner->next;

frankly i figured that this was the wrong way of doing this. and i'm
looking for a better way to accomplish the same goal.  i cant seem to
find the correct function inside libxml2 or dont fully understand the
naming conventions. (again i am a noob)  any help anyone can give me is
greatly appreciated.

2. i have a xmlXPathObjectPtr which points to an array of objects.  one
of those object being a array itself.  (array contained inside an array)
and i cant seem to figure out how to get the subarray from my array. an
example would be like


again if anyone could provide me with any hints i would be very


xml mailing list, project page xml gnome org

Attachment: parse_function.txt
Description: parse_function.txt

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