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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.