RapidXML编译错误解析字符串

时间:2012-07-22 23:27:23

标签: c++ string xml-parsing rapidxml

使用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有四个头文件:

  1. rapidxml_iterators.hpp
  2. rapidxml_print.hpp&lt; - 包含错误,但使用它们构建成功
  3. rapidxml_utils.hpp&lt; - 包含错误,但使用它们构建成功
  4. rapidxml.hpp&lt; - 按程序链接,包含解析函数
  5. 如何解决代码中的错误,首先需要解决标题中的编译错误?

1 个答案:

答案 0 :(得分:0)

@Hydranix在评论中指出,

doc.parse<0>(&str[0]); 

效果很好。我使用它解析了一些大的xml文件。

相关问题