如题 ?

解决方案 »

  1.   

    建议楼主去看下 W3C网站,关于xml的介绍,很详细
      

  2.   

    摘了个简单的实例<html><body>
    <h1>W3School.com.cn Internal Note</h1>
    <p>
    <b>To:</b> <span id="to"></span><br />
    <b>From:</b> <span id="from"></span><br />
    <b>Message:</b> <span id="message"></span>
    </p><script type="text/javascript">
    if(window.XMLHttpRequest){
         xmlhttp = new XMLHttpRequest();
    }
    else{
         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET","/example/xmle/note.xml",false);
    xmlhttp.send();
    xmlDoc = xmlhttp.responseXML;document.getElementById("to").innerHTML=
    xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
    document.getElementById("from").innerHTML=
    xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
    document.getElementById("message").innerHTML=
    xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
    </script></body>
    </html>
      

  3.   

    也转个例子
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=gb2312">
    <title> new document </title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <script type="text/javascript">
    var xmlDoc;
    function loadXML() { // code for IE
    if (window.ActiveXObject) {
    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async = false;
    xmlDoc.load("img.xml");
    getmessage();
    } // code for Mozilla, Firefox, Opera, etc.
    else if (document.implementation && document.implementation.createDocument) {
    xmlDoc = document.implementation.createDocument("", "", null);
    xmlDoc.load("img.xml");
    xmlDoc.onload = getmessage;
    } else {
    alert('Your browser cannot handle this script');
    }
    }
    function getmessage() {
    var nodes = xmlDoc.getElementsByTagName("img");
    note = document.getElementById("div_note");
    for (i = 0; i < nodes.length; i++) {
    img = document.createElement("div");
    img.innerHTML = "<img src=\"" + nodes[i].getElementsByTagName("url")[0].childNodes[0].nodeValue + "\"\\>"
    note.appendChild(img)
    }
    }
    </script>
    </head>
    <body onload="loadXML()">
    <div id="div_note"></div>
    </body>
    </html>
    <?xml version="1.0" encoding="gb2312"?>
    <note>
    <img>
    <title>中國工商銀行1234567890</title>
    <date>2010.05.10</date>
    <url>http://i3.sinaimg.cn/cj/pc/2008-02-28/32/U2328P31T32D40525F651DT20080228150126.jpg</url>
    <content>金融行業領先機構。</content>
    <author></author>
    </img>
    <img>
    <title>中國工商銀行</title>
    <date>2010.05.10</date>
    <url>http://www.51cfp.net/banknetwork/UploadFiles_4962/201004/2010041616241661.gif</url>
    <content>金融行業領先機構。</content>
    <author></author>
    </img>
    </note>
      

  4.   

    http://www.google.com.hk/search?q=JS%E6%93%8D%E4%BD%9CXML
    全都是
      

  5.   

        楼主问问题以前可以先把你的这个问题的标题"javascript操作xml"输入到GOOGLE或百度或CSDN里找一下,相关资料非常多,多看些资料,也许这个问题根本就不用问的!!