
356 • XML & Related Technologies
We would have noticed that the third parameter to the startElement ( ) method is Attributes attrs. In
JAXP, Attributes is defined as an interface. It allows access to a list of attributes of an element by using the
attribute name or index. For this purpose, we need to use the getValue ( ) method of the Attributes interface.
For example, consider the following element:
<PERSON age = “30” title = “Mr”> Prashant </PERSON>
As we can see, the PERSON element has two attributes, namely age and title. When the startElement ( )
method reaches this element, we can call the getValue ( ) method on the attrs object of the Attributes ...