Forum Discussion

bmgriner's avatar
bmgriner
Frequent Contributor
15 years ago

[Res] Iterating over nodes in groovy script

How do you iterate over multiple nodes in an xml response and then pull out data? I have the following xml and I need to check depending on the name tag and then I set a property with the id tag value.

<Response xmlns="https://testsite.com">
<error null="true"/>
<method>http://testsite.com/testmethod/method>
<result>
<e>
<id>123</id>
<name>Main</name>
<type>normal</type>
<unreadPostCount>7</unreadPostCount>
</e>
<e>
<id>3214</id>
<name>Individual</name>
<type>student</type>
<unreadPostCount>3</unreadPostCount>
</e>
</result>
<transactionId>123</transactionId>
</Response>

3 Replies