Parsing XML data
The Document
class provides an easy way for us to store formatted information in an object. In the preceding section's program, we read in information from a cars.xml
file into our Java Document
object. Here's what the cars.xml
file looks like:
<?xml version="1.0"?> <cars> <owner name="Billy"> <car vin="LJPCBLCX11000237"> <make>Ford</make> <model>Fusion</model> <year>2014</year> <color>Blue</color> </car> <car vin="LGHIALCX89880011"> <make>Toyota</make> <model>Tacoma</model> <year>2013</year> <color>Green</color> </car> <car vin="GJSIALSS22000567"> <make>Dodge</make> <model>Charger</model> <year>2013</year>...