While looking through a 3rd party JavaScript API and example code I noticed the following declaration. Basically XML assigned to a string but they seem to split it up on multiple lines using ‘\’, I was unaware this could be done in javascript. Could anyone provide some more details on how this works?
Thanks.
var PrimaryChannel = '<ChannelParams ChannelType="Digital"> \
<DigitalChannelParams \
PhysicalChannelIDType="Cable" \
PhysicalChannelID="107" \
DemodMode="QAM256" \
ProgramSelectionMode="PATProgram" \
ProgramID="2"> \
</DigitalChannelParams> \
</ChannelParams>';
It is escaping the newline character, but it’s not recommended. If you minify your js after the fact, it will break horribly.
You are better off doing something like
or