How can I modify an xml string in java

I am New

New Member
I have an enum which stores numerous xml strings like this\[code\]enum1("<?xml version='1.0'?><!DOCTYPE FOO><FOO><HEADER><MESSAGE-ID>1</MESSAGE-ID><MESSAGE-TYPE>RQ</MESSAGE-TYPE></HEADER>[...someXMLstructure...]</FOO>")enum2("<?xml version='1.0'?><!DOCTYPE FOO><FOO><HEADER><MESSAGE-ID>1</MESSAGE-ID><MESSAGE-TYPE>Q</MESSAGE-TYPE></HEADER>[...someOTHERXMLstructure...]</FOO>")\[/code\]the string is accessed via \[code\]myEnum.getTag()\[/code\]My application takes user input for some of the nodes represented in this string stored as a \[code\]Map<String, String>\[/code\] with the \[code\]key\[/code\] of the \[code\]map\[/code\] being the \[code\]element\[/code\] of the XML doc, and the \[code\]value\[/code\] being the \[code\]value\[/code\]. Essentially i want to copy the XML from the enum and replace any corresponding elements found in the map, then send this message as a \[code\]String\[/code\] over via some third party, unrelated interface. For example the user could pass in \[code\]MESSAGE-ID=3\[/code\] and \[code\]USER-ID=360\[/code\] so we would find the \[code\]MESSAGE-ID\[/code\] element of the string and replace that, then find \[code\]USER-ID\[/code\] in some unknown generic location and replace that. If \[code\]USER-ID\[/code\] isn't found in the XML, then it is simply discarded.EDIT:If there is a better way to do this i.e. convert the XML into some data structure and modify this then convert back to string, I'd be happy to hear it, however I couldn't find much on doing this generically in my searches.Thanks for your help
 
Top