html调用xml

book.xml
<?xml version="1.0" encoding="gb2312"?>
<article>
<title>XML基础</title>
<author>胡千好</author>
<email>[email protected]</email>
<blogname>咖啡迷</blogname>
<url>http://hi.baidu.com/javajavajava</url>
<date>2007年8月</date>
</article>


books.html
<HTML>
<HEAD>
   <TITLE>在html中调用xml数据</TITLE>
   <script language="javaScript" for="window" event="onload">
    var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.load("book.xml");
    nodes=xmlDoc.documentElement.childNodes;
    title.innerText = nodes.item(0).text;
    author.innerText = nodes.item(1).text;
    email.innerText = nodes.item(2).text;
    blogname.innerText = nodes.item(3).text;
    url.innerText = nodes.item(4).text;
    date.innerText = nodes.item(5).text;
   </script>
</HEAD>
<BODY>
   <b>标题:</b><span id="title"></span><br>
   <b>作者:</b><span id="author"></span><br>
   <b>信箱:</b><span id="email"></span><br>
   <b>我的Blog名:</b><span id="blogname"></span><br>
   <b>我的Blog地址:</b><span id="url"></span><br>
   <b>日期:</b><span id="date"></span><br>
</BODY>
</HTML>

你可能感兴趣的:(java,html,xml,Microsoft,Blog)