This class represents the DOM of an HTML document. This can be just an HTML document fragment or a full HTML page. Many different methods and properties are provided to query and modify the HTML document. All classes in DrupalX which generate any kind of HTML data (Menu, Breadcrumb, View, etc.) "forward" any method calls and property get/set operations to this class. This enables you to easily modify any HTML code produced by these classes with just a few lines of code. See the chapter about "HTML transformation" for more information on this topic. The API intentionally stays close to the well-know JavaScript API for DOM manipulation to make it easier to learn. There are only some minor additions (like e.g. the wrap and remove methods) which don't exist in plain JavaScript (but usually exist in JS frameworks like JQuery) but simplify things so much that we decided to include them.
The HTMLDocument class supports all methods and properties of the HTMLElement class - they are not mentioned here again. If you use them on an HTMLDocument, they will automaticalyl apply to the BODY element (which is, of course, possibly only imaginary in case of an HTML document fragement).