Jasper175
14 years agoFrequent Contributor
xmlParser
Hi - I'm working with eviware support, but I wanted to open this up to the forum to see if anyone came up with something that works.
I have an XML Response where all the data has the same tag structure, but the values will be different, and multiples in most cases.
Example:
<m:GetRatedEventListResponse xmlns:m="http://*****">
<m:ratedEvents
<m:eventAttributes>
<m:name>Calling Number</m:name>
<m:value>98989897999</m:value>
</m:eventAttributes>
<m:eventAttributes>
<m:name>Additional charge</m:name>
<m:value>0</m:value>
</m:eventAttributes>
<m:eventAttributes>
<m:name>Called number</m:name>
<m:value>12017726873</m:value>
</m:eventAttributes>
...
What I need to do is parse the output so I can pull only the 'Calling Number' and it's value.
The parser part of the code below is logging everything in the m:name -
def records = new XmlParser().parseText(response)
for (record in records)
for (rec in record['m:name'])
log.info rec.text()
...
However I need to find where m:name == 'Calling Number' and returns it's m:value
![](http://community.smartbear.com/legacyfs/online/smilies/huh.gif)
I have an XML Response where all the data has the same tag structure, but the values will be different, and multiples in most cases.
Example:
<m:GetRatedEventListResponse xmlns:m="http://*****">
<m:ratedEvents
<m:eventAttributes>
<m:name>Calling Number</m:name>
<m:value>98989897999</m:value>
</m:eventAttributes>
<m:eventAttributes>
<m:name>Additional charge</m:name>
<m:value>0</m:value>
</m:eventAttributes>
<m:eventAttributes>
<m:name>Called number</m:name>
<m:value>12017726873</m:value>
</m:eventAttributes>
...
What I need to do is parse the output so I can pull only the 'Calling Number' and it's value.
The parser part of the code below is logging everything in the m:name -
def records = new XmlParser().parseText(response)
for (record in records)
for (rec in record['m:name'])
log.info rec.text()
...
However I need to find where m:name == 'Calling Number' and returns it's m:value
![](http://community.smartbear.com/legacyfs/online/smilies/huh.gif)