Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get attribute names of XML tags in groovy?

 
Nazeer Ahammad
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I need one help. Please see the below xml file content

<students>
<student name="###" id="###" college="###"></student>
<students>

In the above xml, I need to display attribute student tag names(name,id and college).
How can i do this in Groovy.
Please help me.

Thanks,
Nazeer.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember writing a blog post on parsing XML using XmlSlurper in Groovy where I have mentioned how to access the attribute name. The same can be found here.

PS: Sorry for plugging in my blog, but the post serves your query.
 
Pankaja Shinde
Ranch Hand
Posts: 87
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic