1

I fetch an xml file from the internet using a URL

def url = "http://www.kth.se/api/kopps/v1/course/DD1390/round/2014:2/1".toURL()
InputStream inp = url.openStream()
def kursomgXML = new XmlSlurper().parse(inp).declareNamespace(xml:'http://www.w3.org/XML/1998/namespace')

I used the following :

courseRound.courseResponsibleList.courseResponsible.@primaryEmail.list()

which seemed to work fine but when using the result in a method call I get an error saying that no signature of the method is applicable on a value of type groovy.util.slurpersupport.Attribute

How do I get a list of strings instead of a list of slurpersupport attributes?

serafim
  • 75
  • 1
  • 1
  • 9

1 Answers1

2

you can call .text() on the attribute to get a string. or e.g. spread (*.) it over the list

courseRound.courseResponsibleList.courseResponsible.list().'@primaryEmail'*.text()
cfrick
  • 35,203
  • 6
  • 56
  • 68