Chinaunix首页 | 论坛 | 博客
  • 博客访问: 185406
  • 博文数量: 62
  • 博客积分: 1477
  • 博客等级: 上尉
  • 技术积分: 475
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-11 14:28
文章分类

全部博文(62)

文章存档

2012年(62)

我的朋友

分类: 系统运维

2012-07-12 10:58:54

  1. >  
  2.   
  3. <html xmlns="">  
  4. <head runat="server">  
  5.     <title>title>  
  6.     <style type="text/css">  
  7.     style>  
  8.     <script src="../Scripts/jquery-1.4.1.js" type="text/javascript">script>  
  9.     <script type="text/javascript">  
  10.         $(document).ready(function () {  
  11.             $("#Display").click(function () {  
  12.                 $("#message").html('');  
  13.                 $.ajax({  
  14.                     type: "GET",  
  15.                     url: "Friend.xml",  
  16.                     dataType: "xml",  
  17.                     success: function (ResponseText) {  
  18.                         var table = "firstnamelastnamecity";  
  19.                         $(ResponseText).find('friend').each(function () {  
  20.                             var first = $(this).find('firstName').text();  
  21.                             var last = $(this).find('lastName').text();  
  22.                             var city = $(this).find('city').text();  
  23.                             table += "<tr><td>" + first + "td><td>" + last + "td><td>" + city + "td>tr>";  
  24.                         })  
  25.                         table += "table>";  
  26.                         $("#message").append(table);  
  27.                     }  
  28.                 });  
  29.             });  
  30.         });  
  31.     script>  
  32. head>  
  33. <body>  
  34.     <form id="form1" runat="server">  
  35.     <label>Display My Friendslabel><br />  
  36.   <input type="button" value="Display" id="Display" />  
  37.   <div id="message">div>  
  38.     form>  
  39. body>  
  40. html>  

 

  1. xml version="1.0" encoding="utf-8" ?>  
  2. <friends>  
  3.     <friend>  
  4.         <name>  
  5.             <firstName>GuofirstName>  
  6.             <lastName>HulastName>  
  7.         name>  
  8.         <address>  
  9.             <province>Shanghaiprovince>  
  10.             <city>PuDongcity>  
  11.         address>  
  12.     friend>  
  13.     <friend>  
  14.         <name>  
  15.             <firstName>LeifirstName>  
  16.             <lastName>HulastName>  
  17.           
  18.     name>  
  19.         <address>  
  20.             <province>hubeiprovince>  
  21.             <city>xiantaocity>  
  22.         address>  
  23.     friend>  
  24.     <friend>  
  25.         <name>  
  26.             <firstName>JunWenfirstName>  
  27.             <lastName>LilastName>  
  28.         name>  
  29.         <address>  
  30.             <province>hubeiprovince>  
  31.             <city>wuhancity>  
  32.         address>  
  33.     friend>  
  34.     <friend>  
  35.         <name>  
  36.             <firstName>JinhaofirstName>  
  37.             <lastName>LiulastName>  
  38.         name>  
  39.         <address>  
  40.             <province>ShanXiprovince>  
  41.             <city>Taiyuancity>  
  42.         address>  
  43.     friend>  
  44.     <friend>  
  45.         <name>  
  46.             <firstName>ChengfirstName>  
  47.             <lastName>FanglastName>  
  48.         name>  
  49.         <address>  
  50.             <province>GuangDongprovince>  
  51.             <city>GuangZhoucity>  
  52.         address>  
  53.     friend>  
  54. friends> 
阅读(1428) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~