使用RapidXML解析字符串时遇到了一些麻烦。我在Eclipse中收到一条错误,声称解析函数不存在。
make all
Building file: ../search.cpp
Invoking: Cross G++ Compiler
g++ -DDEBUG -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"search.d" -MT"search.d" -o "search.o" "../search.cpp"
../search.cpp: In function ‘void search(CURL*, CURLcode, std::string, std::string)’:
../search.cpp:29:27: error: no matching function for call to ‘rapidxml::xml_document<>::parse(const char*)’
../search.cpp:29:27: note: candidate is:
../rapidxml-1.13/rapidxml.hpp:1381:14: note: template<int Flags> void rapidxml::xml_document::parse(Ch*) [with int Flags = Flags, Ch = char]
make: *** [search.o] Error 1
以下代码引发错误:
rapidxml::xml_document<> doc; // This has no errors
doc.parse<0>(data.c_str()); // This line raises the error (data is a string)
此处参考是在线文档: http://rapidxml.sourceforge.net/manual.html#namespacerapidxml_1parsing
RapidXML有四个头文件:
如何解决代码中的错误,首先需要解决标题中的编译错误?
答案 0 :(得分:0)
@Hydranix在评论中指出,
doc.parse<0>(&str[0]);
效果很好。我使用它解析了一些大的xml文件。