これは私のarty.xmlです:
<child_2 entity_id="2" value="Root" parent_id="1">
<child_4 entity_id="4" value="Activities" parent_id="2">
<child_10066 entity_id="10066" value="Physical1" parent_id="4">
<child_10067 entity_id="10067" value="Cricket" parent_id="10066">
<child_10068 entity_id="10068" value="One Day" parent_id="10067"/>
</child_10067>
</child_10066>
<child_10069 entity_id="10069" value="Test2" parent_id="4"/>
<child_10070 entity_id="10070" value="Test3" parent_id="4"/>
<child_10071 entity_id="10071" value="Test4" parent_id="4"/>
<child_10072 entity_id="10072" value="Test5" parent_id="4"/>
<child_5 entity_id="5" value="Physical" parent_id="4"/>
</child_4>
</child_2>
これはそれを読む私の試みです:
<!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=UTF-8" />
<link rel="stylesheet" type="text/css" media="all" href="style.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<title>Using jQuery and XML to populate a drop-down box demo</title>
<script>
$(document).ready(function(){
$.ajax({
type: "GET",
url: "atry.xml",
dataType: "xml",
success: function(xml) {
var select = $('#mySelect');
$(xml).find('child_2').each(function(){
$(this).find('child_4').each(function(){
var value = $(this).attr('value');
select.append("<option class='ddindent' value='"+ value +"'>"+value+"</option>");
});
});
select.children(":first").text("Select").attr("selected",true);
} //sucess close
});
});
</script>
</head>
<body> <div id="page-wrap">
<select id="mySelect">
<option>loading</option>
</select>
</div>
</body>
</html>
ここでは、すべての属性値をロードして選択リストを作成しようとしています...
しかし問題は、すべての子の値を取得していないことです...
助けてくれ...