说明:
请将以下蓝色部分代码,另存为:x.php
打开页面,即可看到ALERT内容
<?php
if(isset($_GET['x'])){
header("Content-Type:text/xml");
die('
<?xmlversion="1.0"encoding="utf-8"?>
<data>
<phpemail="RunMan@">
<name>Young[夸父]</name>
</php>
<phpemail="tutuyu23@">
<name>Anson</name>
</php>
<javaemail="xiayuanfeng1983@">
<name>Nicholas</name>
</java>
</data>
');
}
?>
<htmlxmlns="/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<scripttype="text/javascript"src="jquery.js"></script>
<scripttype="text/javascript">
$(document).ready(function(){
$.post("x.php?x",function(xml){
$(xml).find("php").each(function(){
alert($(this).children("name").text());
alert($(this).attr("email"));
});
}
)
})
</script>
</head>
</html>