查看文章 |
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> |
最近读者: