-1

下面是我如何调用函数 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);
}

这个函数怎么调用??

4

1 回答 1

0

album[2]是一个std::string。你只需要传递album来匹配vector<string>&参数。

于 2012-09-04T10:23:01.617 回答