title: Parsing XML file in Node.js
body: <p>I am using an Arch Linux system with KDE plasma. I have approximately 50mb XML, and I need to parse it. The file has custom tags. </p>
  
  <p>Example XML:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;JMdict&gt;
     &lt;entry&gt;
        &lt;ent_seq&gt;1000000&lt;/ent_seq&gt;
        &lt;r_ele&gt;
           &lt;reb&gt;ヽ&lt;/reb&gt;
        &lt;/r_ele&gt;
        &lt;sense&gt;
           &lt;pos&gt;&amp;unc;&lt;/pos&gt;
           &lt;gloss g_type="expl"&gt;repetition mark in katakana&lt;/gloss&gt;
        &lt;/sense&gt;
     &lt;/entry&gt;
  &lt;/JMdict&gt;
  </code></pre>
  
  <p>I have tried many solutions that were suggested on Stack Overflow, and they did not work at all, and some of them could not installed to my system like <code>xml-stream</code>, <code>xml2json</code>. I decided to use <code>xml2js</code> (most of them suggest to use <code>xml2js</code>), and got the same result. How can I correctly use it ?
  I am using this code but it always returns undefined:</p>
  
  <pre><code>const fs = require('fs-extra');
  const xml2js = require('xml2js');
  const parser = new xml2js.Parser();
  
  const path = "test.xml";
  
  fs.readFile(path, {encoding: 'utf-8'}, function(error, data) {
       parser.parseString(data, function(err, res) {
           console.log(res);
       });
  });
  
  Result: Undefined
  </code></pre>
  
  <p>Is there any way to handle an XML file by hand (without a package)?</p>