百度首页 | 百度空间
 
查看文章
 
jquery解析XML
2007-11-29 12:50
<!DOCTYPE html PUBLIC "-//W3C// DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">;
<html>
   <head>
     <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
     <title>Address book</title>
     <script src="jquery.js" type="text/javascript"></script>
     <script type="application/javascript">
     $(function() {
         $('#update-target a').click(function() {
             $.ajax({
                 type: "GET",
                 url: "labels.xml",
                 dataType: "xml",
                 success: function(xml) {
                     $(xml).find('label').each(function(){
                         var id_text = $(this).attr('id')
                         var name_text = $(this).find('name').text()

                         $('<li></li>')
                             .html(name_text + ' (' + id_text + ')')
                             .appendTo('#update-target ol');
                     }); //close each(
                 }
             }); //close $.ajax(
         }); //close click(
     }); //close $(
     </script>
   </head>
   <body>
     <p>
       <div id='update-target'>
         <a href="#">Click here to load addresses</a>
         <ol></ol>
       </div>
     </p>
   </body>
</html>

类别:程序一箩筐 | 添加到搜藏 | 浏览() | 评论 (1)
 
最近读者:
 
网友评论:
1
2008-06-24 13:06
你能不能把你解析的XML写出来???
 
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码:
 

     

©2008 Baidu