Forum Discussion

aldana's avatar
aldana
Occasional Contributor
15 years ago

Property expansion xpath style not returning list

Hi,

I am having:

context.expand('${Search#ResponseAsXml#//foo:listItem}')


The xml is:

<foo:root>
  <foo:listItem>...</foo:listItem>
  <foo:listItem>...</foo:listItem>
  <foo:listItem>...</foo:listItem>
</foo:root>


Still above context.expand() only gives me the first of the xml. This way I cannot iterate through list items. Is there an expansion trick to get all list-items?

thanks
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Have you tried using GroovyUtils XmlHolder:

    def gu = new com.eviware.soapui.support.GroovyUtils( context )

    def xml = """<foo:root xmlns:foo="mynamespace">
      <foo:listItem>one</foo:listItem>
      <foo:listItem>two</foo:listItem>
      <foo:listItem>three</foo:listItem>
    </foo:root>"""

    def holder = gu.getXmlHolder(xml)

    holder.getNodeValues("//foo:listItem").each { nValue ->
    log.info nValue
    }