Borrar filtros
Borrar filtros

xmlwrite support for CDATA

1 visualización (últimos 30 días)
Neil
Neil el 20 de Ag. de 2012
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

Respuestas (1)

Dave
Dave el 20 de Ag. de 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',']]>']));

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by