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
Length
— Number of characters in CDATA section
double
Number of characters in the CDATA section, specified as a double.
Attributes:
GetAccess | public |
SetAccess | immutable |
Transient | true |
NonCopyable | true |
TextContent
— Text content of CDATA section
character vector
Text content of the CDATA section, specified as a character vector.
Attributes:
GetAccess | public |
SetAccess | public |
Methods
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
Create a CDATA Section to Output Unescaped Markup Characters
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
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)