Chapter 6. Advanced DOM

Just like in Chapter 4, there’s nothing mystical about anything I’ll cover in this chapter. The topics build upon a foundation that I set in the DOM basics from the last chapter. However, with the exception of the first section on mutation, many of these features are rarely used. While almost everything you’ve seen in SAX (except, perhaps, the DTDHandler and DeclHandler) will be handy, I’ve found many of the fringe features of DOM useful only in specific applications. For example, if you aren’t doing any presentation logic, you’ll probably never touch the DOM HTML bindings. The same goes for many of DOM Level 2’s features; if you need them, you need them badly, and if you don’t, you really don’t.

In this chapter, I’ll present some specific DOM topics that will be useful in your own DOM programming. I’ve tried to organize the chapter more like a reference than the previous chapters; if you want to find out more about the DOM Level 2 Traversal module, for example, you can simply thumb to that section. However, the code examples in this chapter do build upon each other, so you may still want to work through each section in order to get a complete picture of the current DOM model. This results in more practical code samples, rather than useless contrived ones that won’t get you anywhere. So buckle up, and let’s dive a little deeper into the world of DOM.

Changes

First and foremost, I want to talk about the mutability of a DOM tree. The biggest limitation when ...

Get Java and XML, Second Edition 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.