0

How to fetch and read xml file from local system in reactjs? i have tried with xml2js npm package but it dosent have xml read method. Any help is appriciated Thank You

  • Just read the file as a string and pass it into `xml2js`. – Derek Brown Mar 23 '18 at 06:24
  • 1
    Possible duplicate of [How to read a local text file?](https://stackoverflow.com/questions/14446447/how-to-read-a-local-text-file) – Derek Brown Mar 23 '18 at 06:24
  • Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help http://xhr.spec.whatwg.org/ – Pavan Kumar Mar 23 '18 at 09:03
  • above is the error i am getting when i am referening to the code in the above link – Pavan Kumar Mar 23 '18 at 09:04
  • function readTextFile(file) { var rawFile = new XMLHttpRequest(); rawFile.open("GET", file, false); rawFile.onreadystatechange = function () { if(rawFile.readyState === 4) { if(rawFile.status === 200 || rawFile.status == 0) { var allText = rawFile.responseText; } } } rawFile.send(null); } readTextFile("file://D:/sb-code/config.xml"); } – Pavan Kumar Mar 23 '18 at 09:07

0 Answers0