ajax读取XML问题??
<data page=1>
<item>abc</item>
<item>111</item>
<item>333</item>
</data>
请问怎样读取page的值吖??
[解决办法]
<script type="text/javascript">
function test() {
var obj = document.getElementById("page");
alert(obj.page);
}
</script>
</head>
<body>
<data page="1" id="page">
<item>abc</item >
<item>111</item >
<item>333</item >
</data >
<input type="button" name="button" id="button" value="按钮" onclick="test()" />
</body>
[解决办法]
<script type="text/javascript" >
function test() {
var objs = document.getElementsByTagName("data");
alert(objs[0].page);
}
</script >
</head >
<body >
<data page="1" count="10" >
<item >abc </item >
<item >111 </item >
<item >333 </item >
</data >
<input type="button" name="button" id="button" value="按钮" onclick="test()" / >
</body >
[解决办法]
1楼3楼出来吓人的,呵呵
<script type="text/javascript" > function test() { var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");xmlDoc.load(xml1);var pageId=xmlDoc.selectSingleNode("//data").getAttribute("page");alert(pageId);} </script > </head > <body > <xml id="xml1"><data page="1"> <item >abc </item > <item >111 </item > <item >333 </item > </data > </xml><input type="button" name="button" id="button" value="按钮" onclick="test()" / > </body >