使用javascript读取config.xml文件

使用javascript读取config.xml文件,javascript,jquery,config,readfile,Javascript,Jquery,Config,Readfile,我有很多html文件和一个config.xml文件。虽然它们是独立的页面,但它们都属于一个项目。现在我的config.xml文件有了thig标记 <widget xmlns = "http://www.w3.org/ns/widgets" xmlns:gap = "http://phonegap.com/ns/1.0" id = "com.phonegap.capexrevex" version = "1.0.0"> 正如我前面提到的

我有很多html文件和一个config.xml文件。虽然它们是独立的页面,但它们都属于一个项目。现在我的config.xml文件有了thig标记

<widget xmlns = "http://www.w3.org/ns/widgets"
    xmlns:gap = "http://phonegap.com/ns/1.0"
    id        = "com.phonegap.capexrevex"
    version   = "1.0.0"> 

正如我前面提到的,我有很多html页面

在我的主页中,我需要从config.xml文件中读取版本标签


如何使用javascript/jquery来实现这一点???

使用jquery
$。get
函数,您应该能够完成您想要完成的任务

$.get("config.xml", function(data){
    alert($(data).find('widget').attr('version'));
});

注意:最新版本的PhoneGap上的config.xml不在www文件夹中。我知道你可以在www文件夹中有一个,但是如果你要安装PhoneGap的新副本并创建一个新的应用程序,目录结构不再将config.xml放在www文件夹中。。。