search in XmlSlurper result

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

search in XmlSlurper result

Guillaume Alleon
hi,

I do read an xml file through an XmlSlurper:

     wsdl = new XmlSlurper().parseText(server.toURL().text)

I then extract some fields

     operations = []
     operations = wsdl.portType.operation.@name

I would like to check if a string is the list of the extracted fields.

while: operations.each{ println it } prints all the operations.

the following test: if ( operations.contains(aString) ) ... seems to
be invalid.
What is the correct method to query such a thing ?

Thanks
Guillaume

--
Guillaume ALLEON
http://guillaume.alleon.free.fr/wikini
Reply | Threaded
Open this post in threaded view
|

RE: search in XmlSlurper result

Dierk König
I would guess

operations = []
operations = wsdl.portType.operation.@name*.toString()

to make a list of Strings rather than a list of
GPathResult objects.
The *. operator is used for applying a method on all elements
of a list and return a list of results.

cheers
Mittie

> -----Original Message-----
> From: Guillaume Alleon [mailto:[hidden email]]
> Sent: Sonntag, 11. Dezember 2005 21:09
> To: [hidden email]
> Subject: [groovy-user] search in XmlSlurper result
>
>
> hi,
>
> I do read an xml file through an XmlSlurper:
>
>      wsdl = new XmlSlurper().parseText(server.toURL().text)
>
> I then extract some fields
>
>      operations = []
>      operations = wsdl.portType.operation.@name
>
> I would like to check if a string is the list of the extracted fields.
>
> while: operations.each{ println it } prints all the operations.
>
> the following test: if ( operations.contains(aString) ) ... seems to
> be invalid.
> What is the correct method to query such a thing ?
>
> Thanks
> Guillaume
>
> --
> Guillaume ALLEON
> http://guillaume.alleon.free.fr/wikini