On 14/10/2015 16:13, Balachandran Sivakumar wrote:
Hi,

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.

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

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

Use

  root.parent.child.@id

or

  root.parent.child.'@id'

to access the attribute you want.


--
Schalk W. Cronjé
Twitter / Ello / Toeter : @ysb33r

Reply via email to