Reputation:
How can we store an xml data format into a string in javascript. I want to store the xml below. How can we store that xml data below ? Is escaping special characters in a string a solution to that ?
<?xml version="1.0" encoding="UTF-8"?>
<?ADF VERSION="1.0"?>
<adf>
<prospect>
<id sequence="yourLeadID" source="site name"></id>
<requestdate>2013-03-15T8:22:40</requestdate>
<vehicle interest="buy" status="used">
<vin>4RT6FGE6HJ78F3DF56</vin>
<year>2013</year>
<make>Ford</make>
<model>Ford Focus</model>
<stock>4321</stock>
</vehicle>
<customer>
<contact>
<name part="first" type="individual">John</name>
<name part="last" type="individual">XYZ</name>
<email>john at example.com</email>
<phone type="home">111-222-7777</phone>
<phone type="mobile">111-444-5555</phone>
<phone type="work">111-222-3333</phone>
</contact>
<comments>Inquiry regarding vehicle</comments>
</customer>
<vendor>
<contact>
<name part="full">website name from where you are sending email</name>
<email>john at example.com</email>
<phone type="business">111-666-7777</phone>
</contact>
</vendor>
</prospect>
</adf>
Upvotes: 0
Views: 369
Reputation: 10237
You can put it into a string using template literals like this:
const smlString = `
<?xml version="1.0" encoding="UTF-8"?>
<?ADF VERSION="1.0"?>
<adf>
<prospect>
<id sequence="yourLeadID" source="site name"></id>
<requestdate>2013-03-15T8:22:40</requestdate>
<vehicle interest="buy" status="used">
<vin>4RT6FGE6HJ78F3DF56</vin>
<year>2013</year>
<make>Ford</make>
<model>Ford Focus</model>
<stock>4321</stock>
</vehicle>
<customer>
<contact>
<name part="first" type="individual">John</name>
<name part="last" type="individual">XYZ</name>
<email>john at example.com</email>
<phone type="home">111-222-7777</phone>
<phone type="mobile">111-444-5555</phone>
<phone type="work">111-222-3333</phone>
</contact>
<comments>Inquiry regarding vehicle</comments>
</customer>
<vendor>
<contact>
<name part="full">website name from where you are sending email</name>
<email>john at example.com</email>
<phone type="business">111-666-7777</phone>
</contact>
</vendor>
</prospect>
</adf>
`
Upvotes: 1