js解析xml
<!DOCTYPE html>
<html>
<head>
<meta charset=
"UTF-8"
>
<title></title>
<script src=
"../jquery-1.11.2.min.js"
></script>
</head>
<body>
<div id=
"shuju"
></div>
</body>
<script type=
"text/javascript"
>
$.ajax({
url:
"chuli.php"
,
dataType:
"XML"
,
success:
function
(data){
var
zi = $(data).find(
"yonghu"
).children();
var
str =
""
;
for
(
var
i=0;i<zi.length;i++)
{
//zi.eq(i).find("code").text();
var
name = zi.eq(i).find(
"name"
).text();
str = str+
"<div>"
+name+
"</div>"
;
}
$(
"#shuju"
).html(str);
}
});
</script>
</html>