File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Getting the value from an attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Getting the value from an attribute" Watch "Getting the value from an attribute" New topic

Getting the value from an attribute

phillip nash

Joined: Feb 08, 2011
Posts: 21
Hello. I'm starting out using XML within my java program. I've managed to retrieve all of my elements etc, but I dunno how I retrieve my groupNumber (in this case its 3). The structure of my XML file is below, I've omitted the employee data for brevity.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
When you have a "Group" Element, use the methods in org.w3c.dom.Element to manipulate attributes.

While you have the JavaDocs for the org.w3c.dom package open, study the Node Javadocs - there is a table which every XML programmer needs to be familiar with.

I agree. Here's the link:
subject: Getting the value from an attribute
It's not a secret anymore!