Forum Discussion
M_McDonald
14 years agoSuper Contributor
Does this work as well?
String request = context.expand('${updateRequest#Request}')
String toAdd = '''<ns22:references xmlns="http://test.com/rpdesktop/faults/" xmlns:ns2="http://test.com/ws/2010/08/Common" xmlns:ns3="http://test.com/dataservices/ws/2011/09/Order" xmlns:ns4="http://test.com.au/rpservices/ws/2010/08/StructuredAddress" xmlns:ns5="http://test.com.au/rpservices/ws/2010/08/DigitalResource" xmlns:ns6="http://test.com.au/rpservices/ws/2010/08/ExternalReference" xmlns:ns7="http://test.com.au/rpservices/ws/2010/08/CommonEntity" xmlns:ns8="http://test.com.au/rpservices/ws/2010/08/IndividualEntity" xmlns:ns9="http://test.com.au/rpservices/ws/2010/08/User" xmlns:ns10="http://test.com.au/rpservices/ws/2010/08/SystemEntity" xmlns:ns11="http://test.com.au/rpservices/ws/2010/08/OrganisationEntity" xmlns:ns12="http://test.com.au/rpservices/ws/2010/08/Lender" xmlns:ns13="http://test.com.au/rpservices/ws/2010/08/MortgageManager" xmlns:ns14="http://test.com.au/rpservices/ws/2010/08/ValuationFirm" xmlns:ns15="http://test.com/dataservices/ws/2011/01/Security" xmlns:ns16="http://test.com.au/rpservices/ws/2010/08/Valuer" xmlns:ns17="http://test.com.au/rpservices/ws/2010/08/MortgageBroker" xmlns:ns18="http://test.com/dataservices/ws/2011/09/Valuation" xmlns:ns19="http://test.com.au/rpservices/ws/2010/08/Property" xmlns:ns20="http://test.com.au/rpservices/ws/2010/08/Parcel" xmlns:ns21="http://test.com.au/rpservices/ws/2010/08/Transfer" xmlns:ns22="http://test.com/rpdesktop/messages/" xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<ns22:reference xsi:type="ns19:PropertyFeature" ns19:xmlId="X0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns19:feature>BATHZZZ</ns19:feature>
<ns19:value>1</ns19:value>
</ns22:reference>
<ns22:reference xsi:type="ns19:PropertyFeature" ns19:xmlId="X1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns19:feature>BED</ns19:feature>
<ns19:value>3</ns19:value>
</ns22:reference>
</ns22:references>
'''
def requestXml = new XmlSlurper().parseText( request )
def toAddXml = new XmlSlurper().parseText( toAdd )
requestXml.updateRequest.appendNode( toAddXml.reference )
String newRequest = new groovy.xml.StreamingMarkupBuilder().bind { mkp.yield requestXml }
log.info newRequest