Accessing Jane's XML element

This section will help us access the information about the cars owned by Jane, using the following code. I have divided the code to be added to our main() function in six parts:

  1. So, in the pursuit of finding all the cars owned by Jane, let's see what functionality our XML document provides for us right off the bat. If we take a look at code completion to quickly scan through our list of methods, we can call dom from our Document instance. We're going to see the getDocumentElement() method return an element for us:

This is probably a good way to start. This method returns the top-level element in our XML; in ...

Get Java Programming for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.