groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Balachandran Sivakumar <>
Subject GPathResult and attributes
Date Wed, 14 Oct 2015 15:13:00 GMT

         I am using XmlSlurper to parse an xml and I have a GPathResult
from parsing it. I want to get all attributes in the current node pointed
to by GPathResult into a Map. For eg.

  <parent id="1">
    <child1 id="x" attr1="test" attr2="test2"/>
    <child2 id="y" someattr="something"/>

Now, I dd an XmlSlurper().parseText() and then did

def node = root.parent.child1

I was hoping that node would be a NodeChild, but it is actually a
GPathResult object. So, I can't call attributes() on that. Can someone
please help me with this ? Thanks

Thank you
Balachandran Sivakumar

View raw message