私は頭の子ノードの名前を取得しようとします- >テキストノード(したがって、私が書くときにブートが必要です
var headerstyles = xmlDoc.getElementsByTagName("head")[0].getElementsByTagName("style")[0].childNodes;
for (i=0;i<headerstyles.length;i++)
{
alert (headerstyles[i].nodeName);
}
#テキストの色 #テキストのフォント #テキスト
したがって、実際の NodeName を確認する前に、この#text を取得する理由と、これを解決するにはどうすればよいかわかりません。
これが私のコードです
xmlhttp.open("GET","desc.xml",false);
xmlhttp.send();
alert (xmlhttp.responseText);
xmlDoc=xmlhttp.responseXML;
alert (xmlDoc);
var headerstyles = xmlDoc.getElementsByTagName("head")[0].getElementsByTagName("style")[0].childNodes;
for (i=0;i<headerstyles.length;i++)
{
alert (headerstyles[i].nodeName);
}
ここに私のdess.xmlがあります
<docs>
<main>
<bgrnd>
<img> </img>
<color> </color>
</bgrnd>
<head>
<text>Learning about Birds</text>
<style>
<color>red</color>
<font>italic bold 30px Georgia,serif</font>
</style>
</head>
<text>
<link>
<l>
<dscrpt>Lesson 1 - Diet and feeding; Water and Drinking</dscrpt>
<hrf> diet.html </hrf>
</l>
<l>
<dscrpt>Lesson 2 - Feather Care </dscrpt>
<hrf> feather.html </hrf>
</l>
<l>
<dscrpt>Lesson 3 - Level three </dscrpt>
<hrf> item3.html </hrf>
</l>
</link> ... and so on
...................................................................