c++ rapidxml node_iterator 示例?
我刚刚开始使用rapidXML,因为它是别人推荐给我的。现在,为了迭代多个兄弟姐妹,我这样做:
//get the first texture node
xml_node<>* texNode = rootNode->first_node("Texture");
if(texNode != 0){
string test = texNode->first_attribute("path")->value();
cout << test << endl;
}
//get all its siblings
while(texNode->next_sibling() != 0){
string test = texNode->first_attribute("path")->value();
cout << test << endl;
texNode = texNode->next_sibling();
}
作为基本测试,它工作得很好。不管怎样,我遇到了node_iterator,它似乎是一个额外的迭代器类来为我做这件事。无论如何,我找不到任何有关如何使用它的示例,所以我想知道是否有人可以告诉我:)
谢谢!
I just started using rapidXML since it was recommended to me. Right now to iterate over multiple siblings i do this:
//get the first texture node
xml_node<>* texNode = rootNode->first_node("Texture");
if(texNode != 0){
string test = texNode->first_attribute("path")->value();
cout << test << endl;
}
//get all its siblings
while(texNode->next_sibling() != 0){
string test = texNode->first_attribute("path")->value();
cout << test << endl;
texNode = texNode->next_sibling();
}
as a basic test and it works fine. Anyways, I came across node_iterator which seems to be an extra iterator class to do this for me. anyways, I could not find any example on how to use it, so I was wondering if some one could show me :)
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我可以找到的 文档 没有
node_iterator
类型的文档。除了引用输出迭代器之外,我什至在该页面上找不到“迭代器”这个词,而您显然不想要它。它可能是一个内部 API,或者是一个正在开发的 API,所以您现在最好不要使用它。
The documentation that I could find documents no
node_iterator
type. I can't even find the worditerator
on that page except in reference to output iterators, which you clearly don't want.It could be that it's an internal API, or one under development, so you're probably best not to use it right now.
没有RapidXml不提供任何迭代器。您的解决方案是要遵循的解决方案...手动使用函数first_node、next_sibling等...RapidXml被设计得轻巧而快速...即使程序员肯定会欣赏一些语法来帮助他:)
No RapidXml does not provide any iterator. Your solution is the one to be followed... manually using function first_node, next_sibling and so on... RapidXml is made to be light and fast... Even if a programmer would sure appreciate some syntax to help him :)