//xml.xml页面 <div> <div> <aaaa>zhangsan's</aaaa> <bbbb>man</bbbb> </div> <div> <aaaa>lisi <zhangsan </aaaa> <bbbb>woman</bbbb> </div> </div> //jquery页面<script src="jquery-1.7.2.min.js"></script> <script type="text/javascript"> $(function(){ $.post("xml.xml",function(msg){ var _name = $(msg).find("aaaa"); var _sex = $(msg).find("bbbb"); str = '['; for(var i=0;i<_name.size();i++){ str += "{name:'"+_name.eq(i).text()+"',sex:'"+_sex.eq(i).text()+"'}"; } str += "]"; str = str.replace("<","<"); document.write(str); }, 'xml'); }) </script>
用jquery获取xml页面 以json字符串格式输出
最新推荐文章于 2022-08-26 14:35:07 发布