Page 1 of 1

How to modify a nested XML element using Java

Posted: Tue Jul 03, 2018 2:33 pm
by Sweg
I have an XML file stored in src/test/resources.

I am trying to do the following:

1. Retrieve the XML Body
2. Modify a nested element within the body
3. Convert the XML body to a string

Below is a sample XML:

Code: Select all


<Client>
<Name>
</Name>
<Location>
<Address>
<Line1>Test Address<Line1>
</Address>
</Location>
</Client>
So I want to change Client.Location.Address.Line1 within my java method, & then convert that entire XML to a string. But, I don't want to overwrite the original XML.

Can this be done?

Re: How to modify a nested XML element using Java

Posted: Tue Jul 03, 2018 2:45 pm
by Radu
Hi,

This forum is for posting questions related to Oxygen XML Editor.
The Java runtime environment contains a DOM API which allows you to parse XML as a structure of nodes and to modify it:

http://www.tutorialspoint.com/java_xml/ ... cument.htm

Regards,
Radu