File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Groovy and the fly likes How to get attribute names of XML tags in groovy? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "How to get attribute names of XML tags in groovy?" Watch "How to get attribute names of XML tags in groovy?" New topic
Author

How to get attribute names of XML tags in groovy?

Nazeer Ahammad
Ranch Hand

Joined: Feb 26, 2012
Posts: 43
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

Joined: Sep 08, 2007
Posts: 3068
    
  33

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.


Mohamed Sanaulla | My Blog
Pankaja Shinde
Ranch Hand

Joined: Sep 15, 2006
Posts: 87
http://groovy.codehaus.org/Reading+XML+using+Groovy's+XmlParser
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get attribute names of XML tags in groovy?