函数调用std :: vector

时间:2012-09-04 10:20:20

标签: c++

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

如何调用此函数??

1 个答案:

答案 0 :(得分:0)

album[2]std::string。您只需要传递album以匹配vector<string>&参数。