title: How to get and pass a XML string on php to java script from mysql
body: <p>So I got this code:</p>
  <pre><code>                  &lt;input type='button' value='clickme' onclick='download(\&quot;&quot; . $rowtable['Protocolo'] . &quot;.xml\&quot;,\&quot;&quot; . $rowtable['XML']. &quot;\&quot;);'/&gt;&lt;/input&gt;
                    &lt;script&gt;
                    function download(filename, text) {
                      var pom = document.createElement('a');
                      pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
                      pom.setAttribute('download', filename);
                  
                      if (document.createEvent) {
                          var event = document.createEvent('MouseEvents');
                          event.initEvent('click', true, true);
                          pom.dispatchEvent(event);
                      }
                      else {
                          pom.click();
                      }
                  }
                    &lt;/script&gt;
  </code></pre>
  <p>It get 2 result from my DB that is a String(Protocolo) and a TEXT(XML).
  But the thing is my TEXT(XML) data look like this:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;enviNFe versao=&quot;4.00&quot; xmlns=&quot;asdasdasdasdasd&quot;&gt;&lt;idLote&gt;1&lt;/idLote&gt;&lt;indSinc&gt;1&lt;/indSinc&gt;&lt;NFe xmlns=&quot;asdsdasadsad&quot;&gt;
  </code></pre>
  <p>As u can see, it have alot of &quot; on it. And it kind bugs, the code.
  So my question is, how can I transform all this $rowtable['XML'] into a proper string. So I can pass it to the JS so i can download it.</p>
  <p>If u have any better way of downloading this XML data from my DB is welcome aswell.</p>