I'm working in Java with XML and I'm wondering; what's the difference between an element and a node?
A node is the base class for both elements and attributes (and basically all other XML representations too).
A Node is a part of the DOM tree, an Element is a particular type of Node
e.g.
<foo> This is Text </foo>
You have a foo Element, (which is also a Node, as Element inherits from Node) and a Text Node 'This is Text', that is a child of the foo Element/Node
A node can be a number of different kinds of things: some text, a comment, an element, an entity, etc. An element is a particular kind of node.
The Node object is the primary data type for the entire DOM.
A node can be an element node, an attribute node, a text node, or any other of the node types explained in the "Node types" chapter.
An XML element is everything from (including) the element's start tag to (including) the element's end tag.
As described in the various XML specifications, an element
is that which consists of a start tag, and end tag, and the content in between, or alternately an empty element tag (which has no content or end tag). In other words, these are all elements:
<foo> stuff </foo>
<foo bar="baz"></foo>
<foo baz="qux" />
Though you hear "node" used with roughly the same meaning, it has no precise definition per XML specs. It's usually used to refer to nodes of things like DOMs, which may be closely related to XML or use XML for their representation.
Element is the only kind of node that can have child nodes and attributes.
Document also has child nodes, BUT
no attributes, no text, exactly one child element.