Js operation XML source, as a dynamic news page
reference js source code is as follows (save as RSS. Js file) :

var main=document. The getElementById (" content "). The getElementsByTagName (" DIV ");

/* * the current directory a subfolder called XML below, the following reference source stored in the directory.
* 下面每一行的冒号前面是文件名,后面是xml源地址(可以从源址下载得到xml文件,下载后保存为对应文件名)
* 可以在下面的地址上单击右键,选择目标另存为,下载后得到的是txt文件,更改扩展名为xml即可
* movie:"http://news.baidu.com/n?cmd=1&class=film&tn=rss"
* woman:"http://news.baidu.com/n?cmd=1&class=healthnews&tn=rss"
* house:"http://news.baidu.com/n?cmd=1&class=housenews&tn=rss"
* car:"http://news.baidu.com/n?cmd=1&class=autonews&tn=rss"
* sport:"http://news.baidu.com/n?cmd=1&class=sportnews&tn=rss"
* edu:"http://news.baidu.com/n?cmd=1&class=edunews&tn=rss"
*/
var RssSource={
movie: "xml/movie.xml",
woman: "xml/woman.xml",
house: "xml/house.xml",
car: "xml/car.xml",
sport: "xml/sport.xml",
edu: "xml/edu.xml"
}
function Init() {
LoadXml(RssSource.movie, main[0]);
LoadXml (RssSource. Woman, the main [1]).
LoadXml (RssSource. House, main [2]).
LoadXml (RssSource. Car, the main [3]).
LoadXml (RssSource. Sport, the main [4]);
LoadXml (RssSource.edu, main [5]);

} function LoadXml (url, target) {
var XML=null;
var isIE=true;
if (window. ActiveXObject)//if the IE
{
XML=new ActiveXObject (" Microsoft. XMLDOM ");
isIE=true;
} else if (document. Implementation. CreateDocument)//if the FF
{
=XML document. The implementation. The createDocument (" ", "", null);
isIE=false;
}
XML. Async=false;
XML. The load (url);

//for XML document root node var root=XML. The documentElement;
//get the RSS XML source of the item.
var items=root node getElementsByTagName (" item ");
//create a DOm object - RSS title
var head=document. The createElement method (" dt ");
head. SetAttribute (" style ", "background - color: #CCC; cursor: pointer;");
if (isIE) {//IE operations
head. The innerHTML="<b>" + (root. GetElementsByTagName (" title ") [0]. Text), the substring (2, 6) + "</b> <sub>" + root. GetElementsByTagName () "for its pubDate" [0]. Text + </sub> "" ;
target. The appendChild (head);
//to create DOm object - RSS list
var ul=document. The createElement method (" ul ");
//add a list to DIV container
target. The appendChild (ul);
//cycle output daily news to li, among them the items. The length is the news article number
the for (I=0; I <items. The length; i++) {
//create a DOM object li, hold press
var li=document. The createElement method (" li ");
//create a DOM object hyperlink
var lk=document. The createElement method (" a ");

////time the title attribute of the hyperlinks,
lk. Also used to hold the news text title=items [I] selectSingleNode (" title "). The text;
//set the href attribute of the hyperlinks.
lk href=http://www.script-home.com//article/items [I] selectSingleNode (" link "). The text;
//display text hyperlinks, if longer than 15 characters, the interception, then add...
lk. InnerHTML=lk. Title. Length >18? Lk. Title. The substring (0, 16) + "..." Lk. The title;
//lk. The innerText=lk. The title;
//
in the add li to ul ul. The appendChild (li);
//
in the add hyperlinks to li li. The appendChild (lk);

}} else {//the operation of the IE
head. The innerHTML="<b>" + (root. GetElementsByTagName (" title ") [0] textContent). The substring (2, 6) + "</b> <sub>" + root. GetElementsByTagName () "for its pubDate" [0] textContent + </sub> "" ;
target. The appendChild (head);
//to create DOm object - RSS list
var ul=document. The createElement method (" ul ");
//add a list to DIV container
target. The appendChild (ul);
//cycle output daily news to li, among them the items. The length is the news article number
the for (I=0; I <items. The length; i++) {
//create a DOM object li, hold press
var li=document. The createElement method (" li ");
//create a DOM object hyperlink
var lk=document. The createElement method (" a ");

////time the title attribute of the hyperlinks,
lk. Also used to hold the news text title=items [I] getElementsByTagName (" title ") [0] textContent;
//set the href attribute of the hyperlinks.
lk href=http://www.script-home.com//article/items [I] getElementsByTagName (" link ") [0] textContent;
//display text hyperlinks, if longer than 15 characters, the interception, then add...
lk. InnerHTML=lk. Title. Length >18? Lk. Title. The substring (0, 16) + "..." Lk. The title;
//lk. The innerText=lk. The title;
//
in the add li to ul ul. The appendChild (li);
//
in the add hyperlinks to li li. The appendChild (lk);

}}
}

to display the page reference source for HTM pages (save)

<! PUBLIC DOCTYPE HTML "-///DTD/W3C XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<HTML XMLNS="http://www.w3.org/1999/xhtml" >
<Head>
<The link type="text/CSS" rel="stylesheet" href="http://www.script-home.com//article/index.css" >
<Base target="_blank" >
</head>
<Body>
<Div id="pagebody" >
<Div id="header" >
<Div id="banner" ></div>
</div>
<Div id="content" >
<Div class="left" ></div>
<Div class="right" ></div>
<Div class="left" ></div>
<Div class="right" ></div>
<Div class="left" ></div>
<Div class="right" ></div>
</div>
</div>
</body>
</html>
<The script type="text/javascript" SRC="http://www.script-home.com//article/rss.js" ></script>

CSS source (save as index. The CSS)

a: link, a: visited, a: active {
text - decoration: none.
}
a: hover {
text - decoration: underline; #pagebody {
}

margin: 0 auto;
width: 800px;
height: 1200px;
border - left: 1px gray dotted;
border - right: 1px gray dotted;
background - color: #eee; #header {
}

height: 200px; #banner {
}

height: 160px;
background - color: #FFF;

} #content div {
width: 380px;
height: 270px;
border: 1px gray solid;
overflow: hidden;
background - color: #FFF;

} #content div ul li {
the list - style - image: url (list. GIF);

} left {
float: left;
margin - top: 10px;
margin - left: 10px; {
}
right
float: right;
margin - top: 10px;
margin - right: 10px;

}


This concludes the body part