aspose file tools*
The moose likes XML and Related Technologies and the fly likes Attribute Name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Attribute Name" Watch "Attribute Name" New topic
Author

Attribute Name

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Take a look at this xml file.

<credentials>
<name firstname="abc" lastname="xyz" />
</credentials>

Is there any possibility to retrive both the attribute name and attribute value?

I my project I am retriving the element "name" and from that I want retrive both the attribute name and and attribute value

using Element's getAttribute() method we can retrive attribute value in our case "abc" and "xyz"
like

Element e =new Element();
String s1 = e.getAttribute("firstname");
I want to retrive "firstname" and "lastname" also.

Since everything is dynamic, attribute names may be different from time to time. So I wanted to retrive attribute name and from that retrive attribute value.

So one please help me


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
Look at the getAttributes method of org.w3c.dom.Node
It returns a NamedNodeMap with all of the attributes names and values.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Attribute Name