访问本地系统中的xml文件

Accessing xml file in local system

本文关键字:xml 文件 系统 访问      更新时间:2023-09-26

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

if (window.XMLHttpRequest)
  {
      xmlhttp=new XMLHttpRequest();
  }
xmlhttp.open("GET","C:'Users'amit.m2'Desktop'metrics.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
  $.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
      });
     }