当前位置:  开发笔记 > 前端 > 正文

XML中的元素和节点之间有什么区别?

如何解决《XML中的元素和节点之间有什么区别?》经验,为你挑选了8个好方法。

我正在用Java工作,我很想知道; 元素和节点之间有什么区别?



1> Benoit..:

Node对象是整个DOM的主要数据类型.

节点可以是元素节点,属性节点,文本节点或"节点类型"一章中解释的任何其他节点类型.

XML元素是从(包括)元素的开始标记到(包括)元素的结束标记的所有内容.


现在我明白了答案......公约很愚蠢.这些话应该是相反的.在自然英语中,"元素"是最基本的构建块,其中一切都是构建的.即自然英语中的元素更为通用......
@LesHazlewood实际上,"元素"这个词用来描述物理元素(氢,氦等),因为它们*认为那些东西是不可分割的.不久之后,他们发现自己错了 - 改名太迟了; 我同意Sam,他们命名和区分dom元素与节点的方式令人困惑并且思考得很差(尽可能多的html规范).
@SamSvenbjorgchristiensensen,这不太准确.元素可以进一步分解成质子,中子和电子等"组成部分",而这些部分又可以分解成夸克,中微子等.最好理解[图论]中"节点"的含义(http:/ /en.wikipedia.org/wiki/Graph_theory),然后您将理解为什么XML设计者选择了该名称(DOM只是一个分层图).
@Juan Mendes:根据DOM的说法,这就是它们,但Sam的观点是DOM认为节点比元素更基本(原始),而"元素"实际上是指英语中最基本的构建块.
@BT,如果XML规范委员会生活在古希腊,您的论据就会成立:)他们没有这样做,因此,(显然)代表组成部分的元素的现代(词典)定义很有意义。再加上节点的图论知识,实际上没有太大的解释空间。

2> Dimitre Nova..:

不同的W3C规范定义了不同的"节点"类型集.

因此,DOM规范定义了以下类型的节点:

An element is a type of node. Many other types of nodes exist and serve different purposes.- An element is a type of node. Many other types of nodes exist and serve different purposes.(最大的一个的), ,,An element is a type of node. Many other types of nodes exist and serve different purposes. An element is a type of node. Many other types of nodes exist and serve different purposes.An element is a type of node. Many other types of nodes exist and serve different purposes.

An element is a type of node. Many other types of nodes exist and serve different purposes. - ,An element is a type of node. Many other types of nodes exist and serve different purposes.,An element is a type of node. Many other types of nodes exist and serve different purposes., An element is a type of node. Many other types of nodes exist and serve different purposes.,,An element is a type of node. Many other types of nodes exist and serve different purposes.An element is a type of node. Many other types of nodes exist and serve different purposes.An element is a type of node. Many other types of nodes exist and serve different purposes.

An element is a type of node. Many other types of nodes exist and serve different purposes. - 没有小孩

An element is a type of node. Many other types of nodes exist and serve different purposes. - ,An element is a type of node. Many other types of nodes exist and serve different purposes.,An element is a type of node. Many other types of nodes exist and serve different purposes., An element is a type of node. Many other types of nodes exist and serve different purposes.,,An element is a type of node. Many other types of nodes exist and serve different purposes.An element is a type of node. Many other types of nodes exist and serve different purposes.An element is a type of node. Many other types of nodes exist and serve different purposes.

An element is a type of node. Many other types of nodes exist and serve different purposes.- ,An element is a type of node. Many other types of nodes exist and serve different purposes.,An element is a type of node. Many other types of nodes exist and serve different purposes.,An element is a type of node. Many other types of nodes exist and serve different purposes.,,An element is a type of node. Many other types of nodes exist and serve different purposes. An element is a type of node. Many other types of nodes exist and serve different purposes.An element is a type of node. Many other types of nodes exist and serve different purposes.

An element is a type of node. Many other types of nodes exist and serve different purposes.- An element is a type of node. Many other types of nodes exist and serve different purposes.,An element is a type of node. Many other types of nodes exist and serve different purposes.

An element is a type of node. Many other types of nodes exist and serve different purposes. - 没有小孩

An element is a type of node. Many other types of nodes exist and serve different purposes. - 没有小孩

An element is a type of node. Many other types of nodes exist and serve different purposes. - 没有小孩

An element is a type of node. Many other types of nodes exist and serve different purposes. - 没有小孩

An element is a type of node. Many other types of nodes exist and serve different purposes.- ,An element is a type of node. Many other types of nodes exist and serve different purposes.,An element is a type of node. Many other types of nodes exist and serve different purposes., An element is a type of node. Many other types of nodes exist and serve different purposes.,,An element is a type of node. Many other types of nodes exist and serve different purposes.An element is a type of node. Many other types of nodes exist and serve different purposes.An element is a type of node. Many other types of nodes exist and serve different purposes.

An element is a type of node. Many other types of nodes exist and serve different purposes. - 没有小孩

XML信息集(通过XPath的使用)具有一组更小的节点的:

文件信息项

元素信息项

属性信息项

处理指令信息项

未扩展的实体参考信息项

字符信息项

评论信息项目

文件类型声明信息项

未分析的实体信息项

符号信息项

命名空间信息项

XPath具有以下节点类型:

根节点

元素节点

文本节点

属性节点

命名空间节点

处理指令节点

评论节点

您的问题 " 元素和节点之间的区别是什么 " 的答案是:

An element is a type of node. Many other types of nodes exist and serve different purposes.



3> 小智..:

Node是DOM树的一部分,Element是特定类型的Node

例如 This is Text

你有一个foo元素(也是一个Node,因为Element继承自Node)和一个文本节点'This is Text',它是foo元素/节点的子节点


这个简短的例子让我对选定的答案有了更多的了解.

4> Greg Hewgill..:

节点可以是许多不同类型的东西:一些文本,一个注释,一个元素,一个实体等.元素是一种特殊的节点.



5> fenomas..:

如各种XML 规范中所述,a element是由开始标记和结束标记以及其间的内容组成的,或者是空元素标记(没有内容或结束标记).换句话说,这些都是元素:

 stuff 


虽然您听到的"节点"使用的含义大致相同,但每个XML规范都没有精确的定义.它通常用于指代DOM之类的节点,这些节点可能与XML密切相关或使用XML进行表示.



6> Colonel Pani..:

xml文档由嵌套元素组成.元素从其开始标记开始,以其结束标记结束.你可能看到的在HTML中.开始标记和结束标记之间的所有内容都是元素的内容.如果元素由自闭标签(例如
)定义,则其内容为空.

打开标签还可以指定属性,例如.

.在此示例中,属性名称为"class",其值为 "rant".

XML语言没有"节点"这样的东西.阅读规范,这个词不会出现.

有些人非正式地使用"节点"这个词来表示元素,这是令人困惑的,因为一些解析器也赋予这个词一个技术含义(识别"文本节点"和"元素节点").确切的含义取决于解析器,因此除非您说明正在使用的解析器,否则该单词的定义不明确.如果你的意思是元素,说'元素'.



7> Troels Thoms..:

节点是元素和属性的基类(基本上也是所有其他XML表示).



8> eugensk..:

元素是唯一一种节点可以有子节点和属性.

Document还有子节点,但
没有属性,没有文本,只有一个子元素.

推荐阅读
虎仔球妈_459
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有