javascript加载xml文件


function loadXml(xmlPath)
{
    var xmlDoc = null;
    try
    {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    }
    catch(e)
    {
        try
        {
            xmlDoc = document.implementation.createDocument("","",null);
        }
        catch(e)
        {
            alert("xmlDoc创建失败:" + e.message);
        }
    }
    try
    {
        xmlDoc.async = false;
        xmlDoc.load(xmlPath);
    }
    catch(e)
    {
        alert("xml加载失败:" + e.message);    
    }    
    return xmlDoc;
}


你可能感兴趣的:(javascript加载xml文件)