Starter Tutorials

A tutorial site for beginners!

Starter tutorials contains well written tutorials on various technologies. Simple examples have been provided through out the tutorials to help the beginners understand them in a easy way.

Go to Blog »

Problem Statement


Write a Java program to parse the XML document containing car details using SAX API.


Source Code


ex5.xml


ex5.java


Java file: ex5.java


Output

Start Element :cars
Start Element :car
Start Element :company
Company Name : Maruthi
End Element :company
Start Element :model
Model Name : Swift
End Element :model
Start Element :engine
Engine : 1248cc
End Element :engine
Start Element :mileage
Mileage : 20
End Element :mileage
End Element :car
Start Element :car
Start Element :company
Company Name : Hyundai
End Element :company
Start Element :model
Model Name : i20
End Element :model
Start Element :engine
Engine : 1000cc
End Element :engine
Start Element :mileage
Mileage : 15
End Element :mileage
End Element :car
End Element :cars