ios開發 學習積累20161101,ios20161101

來源:互聯網
上載者:User

ios開發 學習積累20161101,ios20161101

20161101

XML的聲明

1 <?XML version="1.0" encoding="UTF-8" ?>

XML文檔必須有根項目

XML 對大小寫敏感

所有XML元素必須有關閉標籤

XML文檔必須加引號

 

在XML中,一些字元擁有特殊的意義,需要實體引用。

 XML 中,有 5 個預定義的實體引用:

&lt; < 小於

&gt; > 大於

&amp; & 和號

&apos; ' 單引號

&quot; " 引號

 

XML的注釋

<!— This is a comment —>

在XML中空格會被保留

 

盡量使用元素來描述資料,而僅僅使用屬性來提供與資料無關的資訊。

中繼資料應當儲存為屬性(資料的資料),資料本身應當儲存為元素。

 

XML驗證

http://www.w3school.com.cn/xml/xml_validator.asp

通過測試Google瀏覽器不能提示錯誤,Firefox瀏覽器可以提示錯誤

 

XML Javascript

建立XMLHttpRequest 對象的文法

1 xmlhttp = new XMLHttpRequest();

老版本的internetExplorer (IE5和IE6)使用ActiveX對象

1 xmlhttp = new ActiveXObject(“Microsoft.XMLHTTP”);

執行個體

 TEST.html 

 1 <!DOCTYPE html> 2 <html> 3 <head> 4     <title></title> 5     <script type="text/javascript"> 6         var xmlhttp; 7         function loadXmlDoc(url){ 8             if (window.XMLHttpRequest) { 9                 xmlhttp = new XMLHttpRequest();10             }else if(window.ActiveXObject){11                 xmlhttp = new ActiveXObject();12             }13             if (xmlhttp != null) {14                 xmlhttp.onreadystatechange = state_change;15                 xmlhttp.open("GET",url,true);16                 xmlhttp.send(null);17             }else{18                 alert("Your browser does not supprot XMLHTTP.");19             }20         }21         function state_change(){22             if (xmlhttp.readyState == 4){23                 //4 = "loaded"24                 if (xmlhttp.status == 200) {25                     //200 = "OK"26                     document.getElementById('A1').innerHTML = xmlhttp.status;27                     document.getElementById('A2').innerHTML = xmlhttp.statusText;28                     document.getElementById('A3').innerHTML = xmlhttp.responseText;29                 }else{30                     alert("Problem retrieving XML data:" + xmlhttp.statusText);31                 }32             }33         }34     </script>35 </head>36 <body>37     <h2>Using the HttpRequest Object</h2>38     <p><b>Status:</b>39     <span id="A1"></span>40     </p>41 42     <p><b>Status text:</b>43     <span id="A2"></span>44     </p>45 46     <p><b>Response:</b>47     <br /><span id="A3"></span>48     </p>49     <button onclick="loadXmlDoc('/note.xml')">Get XML</button>50 </body>51 </html>
View Code

note.xml

1 <?xml version="1.0" encoding="UTF-8"?>2 <note>3 <to>George</to>4 <from>John</from>5 <heading>Reminder</heading>6 <body>Don't forget the meeting!</body>7 </note>
View Code

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.