title: How to read an xml file by browsing in React JS
body: <p>I am trying to read XML file by browsing in local machine using input.</p>
  <p>Here is my code</p>
  <pre><code>import React from &quot;react&quot;;
  import &quot;./App.css&quot;;
  import * as fs from &quot;fs&quot;;
  var parseString = require(&quot;xml2js&quot;).parseString;
  const fileToParse =
    &quot;file:///Users/apple/Documents/Project assignments/NewCCD/Ahmed.xml&quot;;
  function App() {
    const getPath = (e) =&gt; {
      fs.readFile(fileToParse, function (err, data) {
        parseString(data, function (err, result) {
          console.log(result);
        });
      });
    };
  
  return (
      &lt;div&gt;
        &lt;input type=&quot;file&quot; title=&quot;Browse&quot; onChange={getPath} /&gt;
      &lt;/div&gt;
    );
  }
  </code></pre>
  <p>Here I am using the exact path still couldn't able to read file and getting this error.</p>
  <p>TypeError: fs__WEBPACK_IMPORTED_MODULE_3__.readFile is not a function</p>