Previous Section  < Day Day Up >  Next Section

Hour 21. Reading and Writing XML Data

The rise to prominence of Java in the mid-'90s coincided with another dramatic change in the development of computer software: the introduction of Extensible Markup Language (XML).

XML, a format for organizing and storing data so that it can be read by any program, has become ginormous, to borrow my kids' favorite adjective, which means "gigantically enormous."

Thanks to XML, data can be read and written independently of the software used to create it. This is a welcome change from the bad old days, when every program seemed to have its own proprietary and idiosyncratic format.

XML data can be read with a parser, a program that recognizes the format and can extract portions of the data as needed.

During this hour, you will read and write XML data using the XML Object Model (XOM), a Java class library that can accomplish each of the following tasks:

  • Reading XML from a file

  • Extracting XML elements

  • Collecting a set of child elements

  • Reading attribute values for an XML element

  • Writing an XML file

    Previous Section  < Day Day Up >  Next Section