title: How to convert an XML file to a JSON file
body: <p>How do I save the extract data from my Linux directories to JSON? I tried saving it to an XML file already where, if I run the script, it will generate an XML file like &quot;data.xml&quot;.</p>
  <p>I don't know how to convert it to a JSON file.</p>
  <p>This is my XML template inside my Bash script:</p>
  <pre><code>file=~/data.xml
    template=&quot; &lt;Data&gt;\n\
    &lt;date&gt;%d&lt;/date&gt;\n\
    &lt;time&gt;%d&lt;/time&gt;\n\
    &lt;age&gt;%d&lt;/age&gt;\n\
    &lt;place&gt;%s&lt;/place&gt;\n\
    &lt;name&gt;%d&lt;name&gt;\n\&lt;/Data&gt;\n&quot;
  
    echo '&lt;?xml version=&quot;1.0&quot;?&gt;' &gt;&gt; $file
    echo '&lt;List2&gt;' &gt;&gt; $file
  </code></pre>
  <p>template</p>
  <pre><code>printf &quot;$template&quot; &quot;$date&quot;\
                      &quot;$time&quot;\
                      &quot;$age&quot;\
                      &quot;$place&quot;\
                      &quot;$name&quot;\$file   
  #closing tag
  echo '&lt;/List&gt;' &gt;&gt; $file
  </code></pre>