Retrieving the Value of a Specific Node using DOM

The DOM API provides a useful set of classes and methods for moving through a DOM object, but what is lacking are some convenience methods for performing certain operations. For instance, being able to search for a single node and retrieve the corresponding value of that node requires a set of programmatic loops to be executed using the standard DOM API. (Other XML parsers provide better interaction with the Java collection API to provide this functionality.)

Coding a series of loops to retrieve a single value is not always the most convenient way to use DOM. While this may be appropriate for operations where the entire contents of a DOM object must be parsed, it becomes cumbersome when only certain ...

Get J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software 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.