Re: [xml] best way copy of xmlXPathObjectPtr->node



Something like:

xmlNodeSetPtr doSomething(xmlDocPtr doc, const xmlChar* xpath) {
xmlNodeSetPtr ret = NULL;
xmlXPathObjectPtr obj;
......
obj = xmlXPathEval(xpath,ctxt);
if (obj != NULL && obj->type == XPATH_NODESET) {
  ret = obj->nodesetval;
  obj->nodesetval = NULL;
}
if (obj != NULL)
  xmlXPathFreeObject(obj);
......
return ret;
}




                                                                                                              
                         
                      oliverst online d                                                                       
                         
                      e                        To:       xml gnome org                                        
                         
                      Sent by:                 cc:                                                            
                         
                      xml-admin gnome o        Subject:  [xml] best way copy of xmlXPathObjectPtr->node       
                         
                      rg                                                                                      
                         
                                                                                                              
                         
                                                                                                              
                         
                      01/20/2004 07:40                                                                        
                         
                      AM                                                                                      
                         
                                                                                                              
                         
                                                                                                              
                         






Hey!

I wanted to do a function you give a xmlDocPtr and an XPath expression,
that returns a xmlNodeSetPtr, so you don't have to create any
xmlXPathContextPtr. The problem is, that nodesetval is being free'd,
when I call xmlXPathFreeObject() and I haven't found a function in
libxml2 to copy a xmlNodeSetPtr. Is there a better way to get a copy
beside loop through all the nodes and put them in a new xmlNodeSetPtr
one-by-one?

TIA
Oliver
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml










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