This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Originally posted by karthik jayaraman: In XPath context, root node is the "/" document root node for which all the other element notes are children. the document element would be the only (immediate) child of the root node.
No, the immediate children of document node can be comments and processing-intstructions too.
Root Element is the root element of document like <HTML> in case of an HTML document. Then what is root node ?
At least in DOM, there's not much difference between a node and an element. An Element IS-A Node that can perform more specific tasks that is suited for an element along with other tasks that Node can do. It's an inheritence thing An Attribute is a Node too, as well as ProcessingInstruction node, Comment Node, etc. In the context of "trees" and that's what DOM really is, a node is a term often used to denote a particular item Object with relationships to other Objects in the tree (i.e. node has a parent, child siblings, ancestors, descendents, etc.) So what I'm trying to say, root element and root node is the same thing, just depends on the context I suppose. PS. root note and document nodes are two different things
Joined: Nov 14, 2000
Hung Tang I'm sorry to say your explanation about Node and Element is incorrect. It is explained very clear on above two answers. There is no need to repeat. One is "/", One is "/*". In DOM. Document is a Node, Element is a Node, but not vice versa. Karthik Jayaraman's answer is all correct, except he missed a little. That was why I did correct him a little. Thanks! Roseanne [ May 30, 2003: Message edited by: Roseanne Zhang ]