<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>t1.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
try {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
} catch (e) {
try {
xmlDoc = document.implementation.createDocument("", "", null);
} catch (e) {
alert(e.message);
}
}
try {
xmlDoc.async = false;
xmlDoc.load("xmls/students.xml");
var output = "";
var nodes = xmlDoc.getElementsByTagName("student");
for ( var i = 0; i < nodes.length; i++) {
output += "<" + nodes[i].nodeName;
for ( var j = 0; j < nodes[i].attributes.length; j++) {
output += " " + nodes[i].attributes[j].nodeName+"=""+nodes[i].getAttribute(nodes[i].attributes[j].nodeName)+""";
output+="><br />";
for(var k=0;k<nodes[i].childNodes.length;k++){
output += " <" + nodes[i].childNodes[k].nodeName+">";
output += nodes[i].childNodes[k].childNodes[0].nodeValue;
output += "<" + nodes[i].childNodes[k].nodeName+"/><br />";
}
}
output+="</"+nodes[i].nodeName+"><br />";
}
document.writeln(output);
} catch (e) {
alert(e.message);
}
</script>
</head>
<body>
This is my HTML page.
<br>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<students>
<student id="scce001">
<name>Lan</name>
<class>G3T05</class>
<sex>famale</sex>
<birthday>
<year>1990</year>
<month>01</month>
<day>21</day>
</birthday>
</student>
<student id="scce002">
<name>TuDou</name>
<class>G3T05</class>
<sex>male</sex>
<birthday>
<year>1989</year>
<month>01</month>
<day>24</day>
</birthday>
</student>
<student id="scce003">
<name>Lee</name>
<class>G3T05</class>
<sex>male</sex>
<birthday>
<year>1989</year>
<month>09</month>
<day>03</day>
</birthday>
</student>
</students>