本帖最后由 jkil216633 于 2011-08-02 17:00:35 编辑

解决方案 »

  1.   

    测试了IE7,FF3.6<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
        <title>js + xml </title>
        <meta name="Generator" content="EditPlus">
        <meta name="Author" content="">
        <meta name="Keywords" content="">
        <meta name="Description" content="">    <script>
            var loadXML = function(xmlFile) {
                var xmlDoc;
                if (window.ActiveXObject) {
                    
                    xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
                    xmlDoc.async = false;                
                    xmlDoc.onreadystatechange = function() {
                        if (xmlDoc.readyState == 4) {
                            show(xmlDoc);
                        }
                    }
                    xmlDoc.load(xmlFile);
                }
                else if (document.implementation && document.implementation.createDocument) {
                    xmlDoc = document.implementation.createDocument('', '', null);
                    xmlDoc.load(xmlFile);
                    xmlDoc.onload = function() { show(this) }
                }
                else {
                    return null;
                }            return xmlDoc;
            }        var xmlFilePath = "data.xml";
            var xmlDoc = loadXML(xmlFilePath);
            function show(xmlDoc) {
                alert(xmlDoc.documentElement.getElementsByTagName("results")[0].getElementsByTagName("result")[0].getAttribute("startPoint"));
                alert(xmlDoc.documentElement.getElementsByTagName("results")[0].getElementsByTagName("result")[0].getAttribute("stopPoint"));
            }
        </script></head>
    <body>
    </body>
    </html>