现在,我通过简单地重写用户请求的文件来保存我的数据。我的 xml 的结构方式是这样的:
Skeleons root
Skeleton with string name attribute
bone with attributes
bone with attributes
bone with attributes
bone with attributes
end Skeleton
Skeleton with string name attribute
bone with attributes
bone with attributes
bone with attributes
bone with attributes
end Skeleton
....
end Skeletons root
我遍历以查看所需名称的框架是否存在,如果存在我想完全重写它。如果没有,我想将它添加到根元素的底部。
有没有人有这方面的例子?
谢谢
最佳答案
基本上,这只是拆分步骤的问题。
首先,定义一个 TiXmlElement *
并将其设置为 0。遍历 Skeletons
的所有子项。如果找到正确的 Skeleton
,请将 TiXmlElement *
指向它。
其次,如果您还没有找到它(TiXmlElement *
仍然是 0),请创建一个新的骨架并将您的 TiXmlElement *
指向它。
最后,在 TiXmlElement *
下创建一个新骨骼。
关于c++ - 使用 TinyXML 修改文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7108349/