Узлы атрибута не считаются дочерними в DOM?
Моя страница здесь похожа на 5 детей в теле: текст> h1> текст> div> текст> // конец 5 детей
Но не считается ли значение атрибута? Разве свойство childNodes не должно возвращать массив всех типов узлов? С текстом> атрибут> текст> h1> атрибут> текст> div> атрибут> текст> p //etc...
У меня есть эта страница:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DOM testing</title>
<script src="scripts/domTesting3.js" type="text/javascript" charset="utf-8"></script>
</head>
<body bgcolor="#cccccc">
<h1 id="test">Test</h1>
<div id="content">
<p>Examining the DOM2 Core and DOM2 HTML Recommendations</p>
<h2>Browsers</h2>
<ul id="browserList">
<li id="chromeListItem">
<a href="http://www.google.com/chrome/ "title="Get Chrome" id="chrome">Chrome</a>
</li>
<li id="firefoxListItem">
<a href="http://www.getfirefox.com/"title="Get Firefox" id="firefox">Firefox 5.0</a>
</li>
<li>
<a href="http://www.microsoft.com/windows/ie/downloads/" title="Get Microsoft Internet Explorer" id="msie">Microsoft Internet Explorer 9</a>
</li>
<li>
<a href="http://www.apple.com/macosx/features/safari/" title="Check out Safari" id="safari">Safari</a>
</li>
<li>
<a href="http://www.opera.com/download/" title="Get Opera" id="opera">Opera 9</a>
</li>
</ul>
</div>
</body>
</html>
с этим сценарием:
function domTest() {
var le = document.body.childNodes.length;
alert(le);//alerts 5 children where are attribut nodes?
for(i = 0; i < le; i++) {
alert(document.body.childNodes[i].nodeType);
alert(document.body.childNodes[i].nodeName);
alert(document.body.childNodes[i].nodeValue);
}
}
window.onload = domTest;