I have a xml file:
<?xml version="1.0" encoding="UTF-8"?>
<productenv:Envelope>
<productenv:Body>
<products>
<productName>TestProduct</productName>
<productPrice>50.00</productPrice>
</products>
</productenv:Body>
</productenv:Envelope>
I am receiving this file from an external server using PHP. The XML is then passed to a javascript file. Here is what the javascript does with the variable that XML is stored in:
<script type="text/javascript">
var result = "<?php echo $result; ?>"; // $result is the variable that sorts the xml file
console.log(result);
</script>
When I run the code I get this error: Uncaught SyntaxError: Unexpected number. This is because the XML is turned into a string, but the double quotes that surround the 1.0 and UTF-8 are messing up the file.
Is there any way I could make the XML a multiline string that I could parse?