下面是我如何调用函数Xpath.evaluate。由于函数调用错误,这不起作用。请帮忙
std::vector<std::string> album;
xpath.evaluate("*[local-name()=*album*]/text()",album);
xpath.evaluate函数是
void XPath::evaluate(char const* xpath, vector<string>& result) const
throw (Error) {
result.clear();
vector<xmlNodePtr> r;
evaluate(xpath, r);
xmlBufferPtr buff = xmlBufferCreate();
for (size_t i = 0; i < r.size(); ++i) {
xmlSaveCtxtPtr ctxt = xmlSaveToBuffer(buff, "UTF-8",
XML_SAVE_NO_DECL | XML_SAVE_NO_XHTML);
xmlNodePtr clone = xmlCopyNode(r[i], 1);
xmlSaveTree(ctxt, clone);
// OMG
if (clone->doc != NULL && clone->doc != r[i]->doc) {
xmlFreeDoc(clone->doc);
}
else {
xmlFreeNode(clone);
}
xmlSaveFlush(ctxt);
result.push_back(string((char const*) buff->content, buff->use));
xmlSaveClose(ctxt);
xmlBufferEmpty(buff);
}
xmlBufferFree(buff);
}
如何调用此函数??
答案 0 :(得分:0)
album[2]
是std::string
。您只需要传递album
以匹配vector<string>&
参数。