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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)