让 TinyXML 只解析一个节点
我试图弄清楚如何为 TinyXML 提供一个包含多个 XML 节点的缓冲区或文件,并让它一次只解析其中一个。看来 TiXmlDocument::Parse() 有一些功能,因为它返回一个 char const* 指针,并且返回的指针似乎超出了文本。
我想这样做的原因是我可能有截断或格式错误的输入,并且我想尽可能多地解析。例如:
<outer>
<inner a="b">value</inner>
</outer>
<outer>
<inner c="d">again</inner>
</outer>
<outer
I am trying to figure out how to give TinyXML a buffer or file which contains more than one XML node, and have it parse only one of them at a time. It appears that TiXmlDocument::Parse() has some functionality for this, since it returns back a char const* pointer, and the pointer returned seems to be past the text.
The reason I want to do this is that I may have truncated or malformed input, and I want to parse as much as I can. For instance:
<outer>
<inner a="b">value</inner>
</outer>
<outer>
<inner c="d">again</inner>
</outer>
<outer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Parse() 方法是虚拟的,您可以 Parse() 任何 TinyXML 节点。在您的示例中:
TiXmlElement ele;
ele.Parse( p, 0 /* 解析数据可以为空 */, TIXML_ENCODING_UTF8 );
将读入一个元素。
The Parse() method is virtual, you can Parse() any TinyXML Node. In your example:
TiXmlElement ele;
ele.Parse( p, 0 /* the parsing data can be null */, TIXML_ENCODING_UTF8 );
Will read in one element.