Q&A

Q1: When a node is to be added to a nodelist, what are the advantages and disadvantages to performing the two-step process of creating the node and then inserting it?
A1: The disadvantage is obvious—it takes two steps to do what could be done in one step. The advantage is the standard one in computing, where a complex task is broken up into several simpler ones. This makes it more difficult to make accidental insertions and deletions.
Q2: Why are the methods of the document and node objects so similar?
A2: The document object is in fact a node with certain specific components that make it the document. Therefore, whenever you treat it as just another instance of a node, you're using the same properties that the node object has.
Q3:

Get Sams Teach Yourself XML in 24 Hours 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.