修改XML节点,但保持XML文件格式不变 [英] Modify XML node but keep the XML file format intact
本文介绍了修改XML节点,但保持XML文件格式不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何修改XML文件而不进行任何更改,例如属性排序,标记扩展和编码? (我的偏好是DOM API)
How may I modify a XML file without any change like attributes ordering, tag expansion and encoding? (My preference is DOM API)
推荐答案
您可以尝试 VTD-XML 。
由于此库在保持文件内容原样的同时构建索引,因此其操作API将允许修补文件,同时保持其余部分完整。
Since this library builds an index while keeping the file content as-is, its manipulation API will allow to "patch" your file while keeping the rest intact.
使用VTD-XML API,您将能够像DOM树一样导航XML(甚至使用XPath)并进行一些修改(插入元素,插入属性等)
Using the VTD-XML API, you will be able to navigate your XML like a DOM tree (even using XPath) and do some modifications (insert elements, insert attributes, etc.)
这篇关于修改XML节点,但保持XML文件格式不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文