Reading XML Documents with JDOM
Naturally, JDOM can read existing XML documents from files, network sockets, strings, or anything else you can hook a stream or reader to. JDOM does not, however, include its own native parser. Instead it relies on any of a number of very fast, well-tested SAX2 parsers such as Xerces and Crimson.
The rough outline for working with an existing XML document using JDOM is as follows:
Construct an org.jdom.input.SAXBuilder object using a simple no-args constructor.
Invoke the builder's build() method to build a Document object from a Reader, InputStream, URL, File, or String containing a system ID.
If there's a problem reading the document, an IOException is thrown. If there's a problem building the document, a JDOMException ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access