JavaScript & XML

javascript之XML DOM对象
http://www.duduwolf.com/wiki/2007/310.html

<script type="text/javascript">

  function createXMLDOM() {
   var arrSignatures = ["MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0",
      "MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument",
      "Microsoft.XmlDom"];
   for (var i=0; i < arrSignatures.length; i++) {
    try {
     var oXmlDom = new ActiveXObject(arrSignatures[i]);
     return oXmlDom;
    }
    catch (oError) {
    }
    throw new Error("Yous System has NO MSXML");
   }
  }             

  var xmlDom = createXMLDOM();

  var updateLoop = function update() {
   Demo.sayHello("", function(data) {
    var out = "";

    xmlDom.loadXML(data);
    var allActions = xmlDom.getElementsByTagName("action");
   
    var currentAction = null;
    for (var i = 0; i < allActions.length; i++)
    {
     currentAction = allActions[i];
     out = out + "/n" + currentAction.childNodes[0].nodeValue;
    
    }
    alert(out);
    dwr.util.setValue("demoReply", data);    
   });

   updateLoop = setTimeout("update()", 2000);
  }

 </script> 

你可能感兴趣的:(JavaScript & XML)