0

我在位置“C:\Documents and Settings\Nabajyot\Desktop”中有一个名为Vehicle.xml的 XML 文件。

我想使用 jquery 读取 xml 文件。

怎么做???

我正在使用代码:

$(document).ready(function() {

    $.get("C:\Documents and Settings\Nabajyot\Desktop\Vehicle.xml", {}, function (xml) {
        $(xml).find('Vehicle').each(function (i) {
            alert($(this).find("Type").text());
        });
    });

});

但它不工作...

请帮帮我。

4

3 回答 3

0

您可能需要转义硬编码的路径,例如encodeURIComponent

于 2012-09-11T08:59:15.180 回答
0

您可以运行本地 Web 服务器并将 xml 文件放在那里。然后通过http://localhost/path-to-your-file.xml

或者

您可以将其上传到某处并使用该 URL。

编辑:例如: http: //filebin.ca/

于 2012-09-11T08:48:34.040 回答
0

您不能从本地文件系统加载文件,像这样,您需要将其放在 web 服务器上,如 apache www 目录或 htdocs 文件夹并从那里加载。

于 2012-09-11T08:54:45.673 回答