3

I'd like to parse an XML document (SOAP request message) for a particular element. The document is stored in requestContent and looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:udb="http://somenamespace>
    <soap:Header/>
    <soap:Body>
        <udb:ProvideUDBIdentityInformationRequest>
            <udb:RequestID>1</udb:RequestID>
            <udb:IDnumber>1</udb:IDnumber>
            <udb:UnifiedNumber>3</udb:UnifiedNumber>
        </udb:ProvideUDBIdentityInformationRequest>
    </soap:Body>
</soap:Envelope>

My Groovy code looks like this:

def request = new XmlSlurper().parseText(requestContent)
println request.ProvideUDBIdentityInformationRequest.RequestID

However the output is empty whereas I would have expected a "1".

Thanks, Robert

Robert Strauch
  • 12,055
  • 24
  • 120
  • 192

1 Answers1

4

Can you try:

println request.Body.ProvideUDBIdentityInformationRequest.RequestID

(you also have a " missing from the end of the xml declaration, but I guess that's a cut/paste error?)

tim_yates
  • 167,322
  • 27
  • 342
  • 338