matlab.io.xml.dom.CDATASection Class
Namespace: matlab.io.xml.dom
Description
An object of the matlab.io.xml.dom.CDATASection class defines an XML CDATA
section. A CDATA section contains text content that is serialized without escaping XML markup
characters.
A matlab.io.xml.dom.Parser object converts the markup
<![CDATA[...]]> to a CDATASection object. You can
use unescaped characters in the CDATA section markup. For example, you can use
> instead of >. CDATA section markup
facilitates inclusion of computer code and mathematical expressions in XML documents by
eliminating the need to use character entities to indicate >,
<, and other characters.
The matlab.io.xml.dom.CDATASection class is a handle class.
Class Attributes
ConstructOnLoad | true |
HandleCompatible | true |
For information on class attributes, see Class Attributes.
Creation
Create a matlab.io.xml.dom.CDATASection object by using the
createCDATASection method of a matlab.io.xml.dom.Document object.
Properties
Number of characters in the CDATA section, specified as a double.
Attributes:
GetAccess | public |
SetAccess | immutable |
Transient | true |
NonCopyable | true |
Text content of the CDATA section, specified as a character vector.
Attributes:
GetAccess | public |
SetAccess | public |
Methods
appendData |
Specify |
cloneNode |
|
compareDocumentPosition |
To decode the returned value,
For example: import matlab.io.xml.dom.* d = Document("root"); root = getDocumentElement(d); cdata = createCDATASection(d,... "Example of a CDATA section"); appendChild(root,cdata); pos = compareDocumentPosition(cdata,root); if bitor(pos,cdata.DOCUMENT_POSITION_CONTAINS)... == pos disp("root contains CDATA section"); else disp("root does not contain CDATA section"); end |
deleteData |
|
getBaseURI |
|
getData |
|
getLength |
|
getNextSibling |
|
getNodeName | name = getNodeName(thisCDATASection) returns
'#cdata-section'. |
getNodeTypeName | name = getNodeTypeName(thisCDATASection) returns
'CDATA_SECTION_NODE'. |
getNodeValue |
|
getOwnerDocument |
|
getParentNode |
|
getPreviousSibling |
|
getTextContent |
|
insertData |
|
isEqualNode |
This method tests for equality
of nodes, not whether the nodes are handles to the same object. To test for
sameness, use the Nodes that are the same are also equal, but nodes that are equal are not necessarily the same. Normalize documents before testing them for equality because normalization can affect equality. |
isSameNode |
|
replaceData |
Specify |
setData |
Specify |
setNodeValue |
Specify |
setTextContent |
Specify
|
splitText |
|
substringData |
Specify |
Examples
This example shows the difference between the serialized output from markup characters in a Text node and CDATASection node. The example creates a Text node and CDATASection node with text content that includes the markup characters > and <. The output from the Text node represents the markup characters as entities. The output from the CDATASection node includes the unescaped markup characters.
Create a Document object and get the root element.
import matlab.io.xml.dom.* docNode = Document("root_element"); docRootNode = getDocumentElement(docNode);
Create a Text node that contains the code x > 1 | x < 2. Append the node to the root element.
tn = createTextNode(docNode,'x > 1 | x < 2');
appendChild(docRootNode,tn);Create a CDATASection node that contains the same code and append the node to the root element.
cdata = createCDATASection(docNode,'x > 1 | x < 2');
appendChild(docRootNode,cdata);Write the XML to a string.
str = writeToString(DOMWriter,docNode)
str = '<?xml version="1.0" encoding="UTF-16" standalone="no" ?><root_element>x > 1 | x < 2<![CDATA[x > 1 | x < 2]]></root_element>'
Version History
Introduced in R2021a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)