<
script language
=
"
javascript
"
for
=
"
window
"
event
=
"
onload
"
>
var xmlDoc = new ActiveXObject( " Microsoft.XMLDOM " );
xmlDoc.async = " false " ;
xmlDoc.load( " myfile.xml " );
nodes = xmlDoc.documentElement.childNodes;
title.innerText = nodes.item( 0 ).text;
author.innerText = xmlDoc.selectSingleNode( " myfile/author " ).text;
email.innerText = nodes.item( 2 ).text;
date.innerText = nodes.item( 3 ).text;
</ script >
var xmlDoc = new ActiveXObject( " Microsoft.XMLDOM " );
xmlDoc.async = " false " ;
xmlDoc.load( " myfile.xml " );
nodes = xmlDoc.documentElement.childNodes;
title.innerText = nodes.item( 0 ).text;
author.innerText = xmlDoc.selectSingleNode( " myfile/author " ).text;
email.innerText = nodes.item( 2 ).text;
date.innerText = nodes.item( 3 ).text;
</ script >
xmlDoc.selectSingleNode("myfile/author").text 读取一个节点的内容,等效于xmlDoc.documentElement.childNodes.item(X).text