This Is A FineDay

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            93 隨筆 :: 0 文章 :: 69 評論 :: 0 Trackbacks
          <2006年8月>
          303112345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(2)

          我參與的團隊

          隨筆分類

          隨筆檔案

          友情連接

          搜索

          最新隨筆

          最新評論

          閱讀排行榜

          評論排行榜

          <script type="text/javascript">
          var xmlHttp;
          var requestType = "";

          function createXMLHttpRequest() {
          ??? if (window.ActiveXObject) {
          ??????? xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
          ??? }
          ??? else if (window.XMLHttpRequest) {
          ??????? xmlHttp = new XMLHttpRequest();
          ??? }
          }
          ???
          function startRequest(requestedList) {
          ??? requestType = requestedList;
          ??? createXMLHttpRequest();
          ??? xmlHttp.onreadystatechange = handleStateChange;
          ??? xmlHttp.open("GET", "parseXML.xml", true);
          ??? xmlHttp.send(null);
          }
          ???
          function handleStateChange() {
          ??? if(xmlHttp.readyState == 4) {
          ??????? if(xmlHttp.status == 200) {
          ??????????? if(requestType == "north") {
          ??????????????? listNorthStates();
          ??????????? }
          ??????????? else if(requestType == "all") {
          ??????????????? listAllStates();
          ??????????? }
          ??????? }
          ??? }
          }
          ?
          function listNorthStates() {
          ??? var xmlDoc = xmlHttp.responseXML;
          ??? var northNode = xmlDoc.getElementsByTagName("north")[0];
          ???
          ??? var northStates = northNode.getElementsByTagName("state");
          ???
          ??? outputList("Northern States", northStates);
          }

          function listAllStates() {
          ??? var xmlDoc = xmlHttp.responseXML;
          ??? var allStates = xmlDoc.getElementsByTagName("state");
          ???
          ??? outputList("All States in Document", allStates);
          }

          function outputList(title, states) {
          ??? var out = title;
          ??? var currentState = null;
          ??? for(var i = 0; i < states.length; i++) {
          ??????? currentState = states[i];
          ??????? out = out + "\n- " + currentState.childNodes[0].nodeValue;
          ??? }
          ???
          ??? alert(out);
          }
          </script>

          parseXML.xml文件
          <?xml version="1.0" encoding="UTF-8"?>
          <states>
          ??? <north>
          ??????? <state>Minnesota</state>
          ??????? <state>Iowa</state>
          ??????? <state>North Dakota</state>
          ??? </north>
          ??? <south>
          ??????? <state>Texas</state>
          ??????? <state>Oklahoma</state>
          ??????? <state>Louisiana</state>
          ??? </south>
          ??? <east>
          ??????? <state>New York</state>
          ??????? <state>North Carolina</state>
          ??????? <state>Massachusetts</state>
          ??? </east>
          ??? <west>
          ??????? <state>California</state>
          ??????? <state>Oregon</state>
          ??????? <state>Nevada</state>
          ??? </west>
          </states>

          posted on 2006-08-03 10:37 Peter Pan 閱讀(549) 評論(0)  編輯  收藏 所屬分類: JS
          主站蜘蛛池模板: 永清县| 惠水县| 合川市| 沅陵县| 浏阳市| 贵港市| 莱州市| 新和县| 留坝县| 克什克腾旗| 工布江达县| 丽水市| 安乡县| 万山特区| 弥渡县| 哈巴河县| 从化市| 临城县| 道真| 太仓市| 平顺县| 突泉县| 高平市| 黔江区| 宾阳县| 即墨市| 慈溪市| 陵川县| 平远县| 双牌县| 太原市| 桐梓县| 松滋市| 公主岭市| 铜梁县| 镇沅| 营口市| 忻城县| 前郭尔| 天镇县| 南陵县|