从xml文件输入并使用rapidxml进行解析
Input from xml file and parsing using rapidxml
我正在尝试使用c++使用rapidxml做类似的事情
xml_document<> doc;
ifstream myfile("map.osm");
doc.parse<0>(myfile);
并接收以下错误
此行有多个标记-无效的参数"候选者为:void parse(char*)"-无法解析符号"parse"
文件大小可以高达几百万字节。
请帮助
您必须按照官方文档中的规定,首先将文件加载到以null结尾的char缓冲区中。
http://rapidxml.sourceforge.net/manual.html#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c
只需将文件的内容读取到一个char数组中,并使用该数组传递给xml_document::parse()
函数。
如果您使用的是ifstream
,您可以使用以下方法将整个文件内容读取到缓冲区
ifstream file ("test.xml");
if (file.is_open())
{
file.seekg(0,ios::end);
int size = file.tellg();
file.seekg(0,ios::beg);
char* buffer = new char [size];
file.read (buffer, size);
file.close();
// your file should now be in the char buffer -
// use this to parse your xml
delete[] buffer;
}
请注意,我没有编译上面的代码,只是根据记忆写的,但这是大致的想法。查看ifstream
的文档以了解确切的详细信息。无论如何,这应该会帮助你开始。
相关文章:
- Cppcheck生成xml转储文件
- 如何在pugixml中获取节点的内部XML
- C++RapidXml-使用first_node()遍历以修改XML文件中节点的值
- 使用 RapidXML 更新C++中的 XML 节点和属性值
- 使用 RapidXML 解析大型 XML(大小大于 65 KB)文件时出现问题
- 尝试使用 RapidXML 将唯一的 XML 属性追加到节点
- C++/RapidXML:编辑节点并写入新的 XML 文件没有更新的节点
- 在 C++ 中使用 RapidXML 写入 XML 文件
- RapidXML无法解析具有Unicode Intaints的XML
- 如何使用RapidXML读取嵌套的XML
- 使用RapidXML遍历一个简单的DOM Xml文档
- 从xml文件输入并使用rapidxml进行解析
- 使用 RapidXML 解析 Xml 文件时出错
- RapidXml:无法从 XML 文件中获取子项
- RapidXML 是否支持 xml:space= "preserve" ?
- C++ 使用 RapidXml 解析 XML 文件、包装类parse_error期望>
- 如何使用rapidxml C++填充.xml文档
- 使用RapidXML和c++从XML文件构建树
- C++RapidXML-编辑XML文件中的值
- 使用RapidXML读取XML节点