1
我有如下图所示的,我需要用另一个标签更换标签的XML文件:如何用XML中的另一个标签替换一个标签使用Java?
<?xml version="1.0" encoding='utf-8'?>
<result>
<!-- some xml data along with lot of other tags -->
</result>
现在我想这个XML是这样的:正如你所看到result
代码被替换ClientHolder
标签其他result
标签中的其他内容也与ClientHolder
标签相同。
<?xml version="1.0" encoding='utf-8'?>
<ClientHolder xmlns="http://www.host.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.host.com model.xsd">
<!-- some xml data along with lot of other tags -->
</ClientHolder>
这里是我到目前为止的代码后,我无法理解如何使用Document对象上面做的东西:
String fileName = location + "/" + "client_" + clientId + ".xml";
File clientFile = new File(fileName);
Document doc = parseXML(clientFile);
// now how to use doc object?
好问题。我不知道你的问题。 – T8Z
检查http://stackoverflow.com/questions/1299926/changing-node-name-of-xml-node-with-java – user2953113