DOM 处理中的常见错误是希望元素节点包含文本。 在本例中:<title>DOM 教程</title>,元素节点 <title>,包含值为 "DOM 教程" 的文本节点。
英文类似意思原文如下: Text is Always Stored in Text Nodes A common error in DOM processing is to expect an element node to contain text. However, the text of an element node is stored in a text node. In this example: <year>2005</year>, the element node <year>, holds a text node with the value "2005"."2005" is not the value of the <year> element! 在处理DOM中,一个常见的错误是以为一个元素节点会包含文本。 然而,元素节点的文本是储存在文本节点中的。 举个例子,<year>2005</year>,元素节点<year>,持有一个文本节点,这个文本节点的值是"2005",而"2005"不是<year>这个元素的值!(是这个元素节点的子节点(文本节点))!
DOM 处理中的常见错误是希望元素节点包含文本。
在本例中:<title>DOM 教程</title>,元素节点 <title>,包含值为 "DOM 教程" 的文本节点。
英文类似意思原文如下:
Text is Always Stored in Text Nodes
A common error in DOM processing is to expect an element node to contain text.
However, the text of an element node is stored in a text node.
In this example: <year>2005</year>, the element node <year>, holds a text node with the value "2005"."2005" is not the value of the <year> element!
在处理DOM中,一个常见的错误是以为一个元素节点会包含文本。
然而,元素节点的文本是储存在文本节点中的。
举个例子,<year>2005</year>,元素节点<year>,持有一个文本节点,这个文本节点的值是"2005",而"2005"不是<year>这个元素的值!(是这个元素节点的子节点(文本节点))!