我在互联网上找到了pugixml,它是一个非常好的库,特别是对于它的格式(只是一个头/源组合,没有dll依赖)。我的问题是,我为我的引擎制作了一个格式,但是我无法获得所有xml节点,只有前三个节点,然后整个乐趣停止。我的xml看起来像这样
<Model>
<Actor childcount="394" meshcount="0" name="sponza.obj">
<Transform 00="1" 01="0" 02="-0" 03="0" 10="0" 11="1" 12="-0" 13="0" 20="-0" 21="-0" 22="1" 23="-0" 30="0" 31="0" 32="-0" 33="1" />
<Actor childcount="0" meshcount="1" name="sponza_00">
<Mesh name="sponza_00-0.mesh" />
<Transform 00="1" 01="0" 02="-0" 03="0" 10="0" 11="1" 12="-0" 13="0" 20="-0" 21="-0" 22="1" 23="-0" 30="0" 31="0" 32="-0" 33="1" />
</Actor>
<Actor childcount="0" meshcount="1" name="sponza_01">
<Mesh name="sponza_01-0.mesh" />
<Transform 00="1" 01="0" 02="-0" 03="0" 10="0" 11="1" 12="-0" 13="0" 20="-0" 21="-0" 22="1" 23="-0" 30="0" 31="0" 32="-0" 33="1" />
</Actor>
<Actor childcount="0" meshcount="1" name="defaultobject">
<Mesh name="defaultobject-0.mesh" />
<Transform 00="1" 01="0" 02="-0" 03="0" 10="0" 11="1" 12="-0" 13="0" 20="-0" 21="-0" 22="1" 23="-0" 30="0" 31="0" 32="-0" 33="1" />
</Actor>
<Actor childcount="0" meshcount="1" name="sponza_03">
<Mesh name="sponza_03-0.mesh" />
<Transform 00="1" 01="0" 02="-0" 03="0" 10="0" 11="1" 12="-0" 13="0" 20="-0" 21="-0" 22="1" 23="-0" 30="0" 31="0" 32="-0" 33="1" />
</Actor>
</Actor>
</Model>
我正在使用示例树助行器
struct simple_walker : pugi::xml_tree_walker
{
virtual bool for_each(pugi::xml_node& node)
{
for (int i = 0; i < depth(); ++i) std::cout << " "; // indentation
std::cout << "- name='" << node.name() << "'\n";
return true; // continue traversal
}
};
但应用程序只写这个
- name='Model'
- name='Actor'
- name='Transform'
即使xml文档中有更多标签。
答案 0 :(得分:4)
问题是XML格式不正确。
属性名称不能以数字开头,即00="1"
不是有效的XML。