jqGrid XML generating with xmlJsonClass, cdata cells
I'm using this code in order to generate XML from my grid's cells values:
var grid = $("#MyGrid");
var dataFromGrid = grid.jqGrid ('getRowData');
var xml_string = '<rows>' + xmlJsonClass.json2xml ({MyGridRow: dataFromGrid}, '\t') + '</rows>';
Inside my grid I have cells that contain XML tags (f开发者_高级运维or example:
<cell1><b><h1>aaa</h1><b></cell1>
I want this data of a specific column to be inside a CDATA (so I will be able later to parse it as XML). How can I add a CDATA tag to the generation of "xmlJsonClass.json2xml"?
The source code of the json2xml
function, which you use, consists of about 60 lines. It seems to me that the easiest way to implement your requirements would be to modify the code.
If you add 3 lines of code
else if (v[m].charAt(0) === "<") {
xml += toXml("<![CDATA[" + v[m] + "]]>", m, ind+"\t");
}
you will see the results in the demo.
精彩评论