i have an xml element
<base baseAtt1="aaa" baseAtt2="tt">
<innerElement att1="one" att2="two" att3="bazinga"/>
</base>
and i would like to get the list of attributes.
for both the base element and the inner element.
i dont know the name of the innerElement
it can have many different names.
NodeList baseElmntLst_gold = goldAnalysis.getElementsByTagName("base");
Element baseElmnt_gold = (Element) baseElmntLst_gold.item(0);
the goal is to get a kind of dictionary as output,
for example for the xml above the output will be a dictionary with those valuse.
baseAtt1 = "aaa"
baseAtt2 = "tt"
att1 = "one"
att2 = "two"
att3 = "bazinga"
i am using jre 1.5
Best Solution
Here is plain DOM based solution (however there is nothing wrong to combine XPath with DOM in Java):
Result: