How to keep a HTML file including CDATA non corrupted when you store it on MongoDB

870Express

New Member
I am trying to store and retrieve on MongoDB HTML files which include CDATA in it. Here is an example of what I want to store (excerpt):\[code\]<campaign id="2" name = "campaign_name"><legal><![CDATA[<b>TERMS AND CONDITIONS</b><br /><br />Click <a href="http://server.com/cgu.php" target="_blank">here</a> to access our terms and conditions.<br /><br />]]></legal><head bgcolor="FFFFFF" bg="" logo="http://server.com/companyname.png"></head>\[/code\]The result I am seeking is to have a JSON looking like this:\[code\]{"_id" : ObjectId("515c4c2c036467046257f51d"),"version" : NumberLong(528),"name" : "VW-test","type" : "Public","about" : ObjectId("515c4c2c036467046257f51c"),"author" : { "name" : "Admin", "image" : "", "id" : NumberLong(1), "namespace" : "server.com"},"image" : "http://server.com/resources/2/medias/1-trig.png","campaign" : { "id" : NumberLong(2), "name" : "admin", "legal" : "<![CDATA[<b>TERMS AND CONDITIONS</b><br /><br />Click <a href="http://server.com/cgu.php" target="_blank">here</a> to access our terms and conditions.<br /><br />", "head" : { "bg" : "", "bgcolor" : "FFFFFF", "logo" : "http://server.com/companyname.png", "value" : "\n " }\[/code\]and right now I get this (showing just the code that has the issue):\[code\]"legal" : "<b>TERMS AND CONDITIONS</b><br /><br />\nClick <a href=http://stackoverflow.com/"http://server.com/cgu.php\" target=\"_blank\">here</a> to access our terms and conditions.<br /><br />\n\n ",\[/code\]Anyone has an idea on how to solve this?
 
Back
Top