What's the difference between an element and a

2020-01-25 03:03发布

I'm working in Java with XML and I'm wondering; what's the difference between an element and a node?

标签: xml xmlnode
13条回答
\"骚年 ilove
2楼-- · 2020-01-25 03:41

Now i know ,the element is one of node

All node types in here"http://www.w3schools.com/dom/dom_nodetype.asp"

Element is between the start tag and end in the end tag

So text node is a node , but not a element.

查看更多
We Are One
3楼-- · 2020-01-25 03:42

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.

查看更多
何必那么认真
4楼-- · 2020-01-25 03:42

XML Element is a XML Node but with additional elements like attributes.

<a>Lorem Ipsum</a>  //This is a node

<a id="sample">Lorem Ipsum</a>  //This is an element
查看更多
欢心
5楼-- · 2020-01-25 03:43

A node is defined as:

the smallest unit of a valid, complete structure in a document.

or as:

An object in the tree view that serves as a container to hold related objects.

Now their are many different kinds of nodes as an elements node, an attribute node etc.

查看更多
SAY GOODBYE
6楼-- · 2020-01-25 03:43

node & element are same. Every element is a node , but it's not that every node must be an element.

查看更多
小情绪 Triste *
7楼-- · 2020-01-25 03:48

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.

查看更多
登录 后发表回答