• Post Reply Bookmark Topic Watch Topic
  • New Topic

DOM Parser - How To Get the Attribute Value  RSS feed

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an XML file that indicates role specific authorization:

I am coding in Java to parse this XML file.

With the "role" and "action" provided, I wish my Java method return a boolean, which is either a "Y" or a "N".

I have managed to drill down the hierarchy. For example,


But, I do not know how to handle XML elements with a number of attributes.

I have many "entries" under the "userrole". How do I get the boolean value of the "access" attribute for the actionType provided?
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
private String unmarshallEntityAttribute( Node node, String actionType ){
NamedNodeMap map = node.getAttributes();
System.out.println("access value: " + map.getNamedItem ("access").getNodeValue());}



 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your guidance. I got the idea. My code is working now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!