日期:2014-05-16 浏览次数:20710 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
function ajax(url, fnSucc, fnFaild)
{
//1.创建ajax对象
var oAjax=null;
if(window.XMLHttpRequest)
{
oAjax=new XMLHttpRequest();
}
else
{
oAjax=new ActiveXObject("Microsoft.XMLHTTP");
}
oAjax.open('GET', url, true);
oAjax.send();
oAjax.onreadystatechange=function ()
{
if(oAjax.readyState==4)
{
if(oAjax.status==200)
{
fnSucc(oAjax.responseText);
}
else
{
if(fnFaild)
{
fnFaild();
}
}
}
};
}
</script>
<script>
window.onload=function ()
{
ajax('books.xml',function (str)
{
alert("如何得到xml值如Lee或hhh")
}
)
}
</script>
</head>
<body>
</body>
</html>
<root>
<user>Lee</user>
<email>yc</email>
<url>http://www.baidu.com</url>
</root>
<root>
<user>ddd</user>
<email>hhh</email>
<url>http://www.baidu.com</url>
</root>
<roots><root>
<user>Lee</user>
<email>yc</email>
<url>http://www.baidu.com</url>
</root>
<root>
<user>ddd</user>
<email>hhh</email>
<url>http://www.baidu.com</url>