Using c# I am trying to write a function that receives an XML file, and outputs a JavaScript file with XML content assigned to a string variable
example
XML input: a.xml
<root>
<book id="a">
SAM
</book>
<book id="b">
</book>
MAX
</root>
JS Output: b.js
var xml = "<root><book id='a'>SAM</book><book id='b'></book>MAX</root>";
Im looking for a simple way to create a legal output as trying to manually escape all xml chars to create a legal js string will surely fail.
any ideas how this can be done painlessly ?