访问本地系统中的xml文件

时间:2014-10-06 08:50:54

标签: javascript xml xml-parsing

我的本​​地系统(不在服务器上)有一个xml文件。我想用javascript访问它来解析它,我该怎么办?我试着给出本地文件位置。

if (window.XMLHttpRequest)
  {
      xmlhttp=new XMLHttpRequest();
  }

xmlhttp.open("GET","C:\Users\amit.m2\Desktop\metrics.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

1 个答案:

答案 0 :(得分:-1)

  $.ajax({
          url: 'input.xml', // Name of the file in the local
          dataType: "xml", // input file type
          success: parse, // Call the parse function on success`enter code here` response
     error: 
        function(){
            alert("Unable to load or something is Wrong !!!");
         }
        });

      function parse(document){
      $(document).find("Inputdata").each(function(){
        // Business logic goes here
      });
     }
相关问题