开发者

Get TinyXML to parse just one node

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>
    <in开发者_StackOverflowner c="d">again</inner>
</outer>
<outer


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜