O'Reilly logo

Java Programming for Beginners by Mark Lassoff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading XML data

In this section, we'll accomplish a very simple task to get ourselves started on the road to learning how Java interacts with XML. We'll use the XML information from the cars.xml file, provided in the code file of the book. This file should be stored in the current directory of our Java project, so when we run our Java program, it will be able to access cars.xml without any additional pathing required. We'll edit the following Java program to load the cars.xml file:

package loadinganxmlfile; import java.io.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; import org.w3c.dom.*; import org.xml.sax.*; public class LoadingAnXMLFile { public static ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required