Hi, Im using xpath and it works well with the examples. But I would like to know if its possible to reuse a xmlDocPtr
and xmlXPathContextPtr for several xpath-parsing on the same document ? I have made tests, the first xpath-parsing was correct with
all datas but the second xpath-parsing returned me the nodes without attributes
and children. Here is the code : xmlDocPtr doc; xmlXPathContextPtr
xpathCtx; xmlInitParser(); xmlXPathInit(); xmlKeepBlanksDefault(0); doc =
xmlReadFile("TestFESA210.xml",NULL, 0); if (doc
== NULL) { string
err("Invalid XML document\n"); throw
(err); } xpathCtx
= xmlXPathNewContext(doc); if(xpathCtx
== NULL) { string
err("Error: unable to create new XPath context\n"); throw
(err); } cout
<< "PREMIER XPATH" << endl; xpathParsing(xpathCtx,"*[contains(name(),'toto')]"); // xmlXPathEvalExpression function cout
<< endl << "SECOND XPATH" << endl; xpathParsing(xpathCtx,"*[contains(name(),'toto')]");
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
xmlCleanupParser(); xmlMemoryDump(); Thanks and best regards. Deff. Qui vous permet denregistrer la TV sur votre PC et lire vos emails sur votre mobile ? la rénse en vidéla rénse en vidé/a> |