In this section, you will learn to retrieve the attributes and their value from a XML document using the SAX APIs.
Description of program:
This program helps you in retrieving attributes and
their values. The parse() method is invoked by the SAXParser
startElement() method in
class to provide functionality to get the attribute and its
value from a xml file.
Here is the XML File: sample.xml
<Employee name="Amit" >
<item code="111" type="CD" label=" music" />
<item code="222" type="DVD" label=" video"/>
Here is the Java File: ReadAttributes.java
Output of this program:
Enter a xml file name: sample.xml
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.