After applying the following XPath expression (based on XPath tutorial):
xmlXPathEval("//*[@xlink='true']", doc)
you obtain a link to the node list. In the example it is a single node folder
with id
4
. Then you need to write a function that will travell all the parents and concatenate their name
attributes.
If you needed only the name of the matching folder, than you could go with
xmlXPathEval("string(//*[@xlink='true']/@name)", doc)
and read the stringval
member of the result. But that matches only the first node.
Edit: As for the function to iterate over parents I thought of direct access through xmlNodePtr->parent
member and reading attributes with xmlGetProp
. But as I see your comment (and also the title of the question) I think that you could make use of relative xpath queries, see What's the most efficient way to do recursive XPath queries using libxml2?.