I have an XML file as shown below in which I need to replace a tag with another tag:
<?xml version="1.0" encoding='utf-8'?>
<result>
<!-- some xml data along with lot of other tags -->
</result>
Now I want this XML to be like this: As you can see result
tag is replaced with ClientHolder
tag and everything else within result
tag is same in ClientHolder
tag as well.
<?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>
Here is my code so far and after that I am not able to understand how to use Document object to do above stuff:
String fileName = location + "/" + "client_" + clientId + ".xml";
File clientFile = new File(fileName);
Document doc = parseXML(clientFile);
// now how to use doc object?