Groovy web console

subscribe to the feed Subscribe
to this
site
namespace xml (via #groovywebconsole)
tweet this snippet Tweet
this
script

namespace xml

Published 6 months ago by nmrao with tags namespace
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def xml = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:w3="http://www.w3.org/"> <soapenv:Header /> <soapenv:Body>     <w3:PerformScan>         <w3:request>             <w3:SearchConfiguration>                 <w3:ConfidenceThreshold>?</w3:ConfidenceThreshold>                 <w3:ResultConfiguration></w3:ResultConfiguration>                 <w3:ScanRequest xsi:type="w3:CustomerRequest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                     <w3:CustomerId>?</w3:CustomerId>                     <w3:CustomerName>?</w3:CustomerName>                 </w3:ScanRequest>             </w3:SearchConfiguration>         </w3:request>     </w3:PerformScan> </soapenv:Body></soapenv:Envelope>"""
def parsedXml = new XmlSlurper().parseText(xml)
//def performScan = parsedXml.'**'.find{ it.name() == 'PerformScan'}
println groovy.xml.XmlUtil.serialize(parsedXml)