Forum Discussion
Hi Rupert,
Yeah ,so I have an inhouse built(java-groovy) application which generates a SOAP response and I have to feed that response to a proprietory software .But before sending the response to the software I need to update few tag values as per the Excel received from third party.
For now I have manually updated the third party Excel column headers with XPATHs of the XML so that I can update the XMLs as per the values in the corresponding row.
My main problem is reading the column header and passing its value in place of
Envelope.Body.CamCommand.CamAction.tCANOTIFICATIONS.pCASECIDUNDL
in the below code
String fileContents = new File(FilePath).text def xmlfromFile = new File(FilePath) def Envelope = new XmlSlurper().parseText(xmlfromFile.getText()) Envelope.Body.CamCommand.CamAction.tCANOTIFICATIONS.pCASECIDUNDL = "NewData123" XmlUtil xmlUtil = new XmlUtil() println xmlUtil.serialize(Envelope) xmlUtil.serialize(Envelope, new FileWriter(xmlfromFile))
Thanks,
Amitav
The below link is having an example, Hope this will help
https://github.com/Vignesh-Sakkarai/ParseAndUpdateXML/blob/master/MainXMLParser.groovy