xmlwrite support for CDATA
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
Am trying to use xmlwrite to generate an xmlfile with CDATA however the resulting xml does not wrap xml tags around the data e.g.
docNode = com.mathworks.xml.XMLUtils.createDocument('DataItem');
docRootNode = docNode.getDocumentElement;
thisElement = docNode.createElement('Sql');
thisElement.appendChild(docNode.createCDATASection('This should be in CDATA'));
docRootNode.appendChild(thisElement);
xml = xmlwrite(docNode);
disp(xml)
Results in
<?xml version="1.0" encoding="utf-8"?>
<Sql>This should be in CDATA</Sql>
When I would expect
<?xml version="1.0" encoding="utf-8"?>
<Sql> <![CDATA[This should be in CDATA]]></Sql>
Am I doing something wrong here, I am not an XML expert
0 Kommentare
Antworten (1)
Dave
am 20 Aug. 2012
This appears to be a widely reported problem. It seems that you can hard-code the delimiters as follows: thisElement.appendChild(docNode.createCDATASection(['<![CDATA[','This should be in CDATA',']]>']));
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!