필터 지우기
필터 지우기

xmlwrite support for CDATA

조회 수: 2 (최근 30일)
Neil
Neil 2012년 8월 20일
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

답변 (1개)

Dave
Dave 2012년 8월 20일
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',']]>']));

카테고리

Help CenterFile Exchange에서 Structured Data and XML Documents에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by