• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Attribute Name

 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the getAttributes method of org.w3c.dom.Node
It returns a NamedNodeMap with all of the attributes names and values.
Bill
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic