*
The moose likes Product and Other Certifications and the fly likes Difference root element/root node Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "Difference root element/root node" Watch "Difference root element/root node" New topic
Author

Difference root element/root node

Nitin Gogia
Greenhorn

Joined: Jan 17, 2003
Posts: 22
Can anyone clarify the difference between root element and root node.
Root Element is the root element of document like <HTML> in case of an HTML document. Then what is root node ?
Karthik Jayaraman
Greenhorn

Joined: May 06, 2003
Posts: 25
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.


Karthik Jayaraman.<br />IBM Certified Developer - XML and Related Technologies.<br />Sun Certified Developer for java WebServices.<br />Sun Certified Java Programmer.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
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.
Hung Tang
Ranch Hand

Joined: Feb 14, 2002
Posts: 148

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
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference root element/root node
 
Similar Threads
Node, Element and Document...
What's the difference - document root & document element?
Root node
basic doubt: doc element and doc root
XSLT/XML