DOMException

You've probably noticed that many of the methods so far have been declared to throw a DOMException. This class shown in Example 9.15 is the generic exception for essentially anything that can go wrong while working with DOM—from logical errors like making an element one of its own children to implementation bugs. Although it is a runtime exception that does not have to be caught, I nonetheless recommend that you always catch it or declare that your method throws it. Conceptually, this should be a checked exception; however, many languages that DOM supports, including C++ and Python, don't have checked exceptions, so DOM uses runtime exceptions in order to keep the semantics of the various methods as similar as possible across languages. ...

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX 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.