matlab.io.xml.dom.Text Class
Namespace: matlab.io.xml.dom
Description
An object of the matlab.io.xml.dom.Text
class represents the text content
of an XML document.
The matlab.io.xml.dom.Text
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.Text
object by using the
createTextNode
method of a matlab.io.xml.dom.Document
object.
Properties
Number of characters in the text content of this node, specified as a double.
Attributes:
GetAccess | public |
SetAccess | immutable |
Transient | true |
NonCopyable | true |
Text content of this text node, specified as a character vector.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Methods
appendData |
Specify
|
cloneNode |
|
compareDocumentPosition |
For example: import matlab.io.xml.dom.* d = Document("root"); root = getDocumentElement(d); text = createTextNode(d,"Hello"); appendChild(root,text); pos = compareDocumentPosition(text,root); if bitor(pos,text.DOCUMENT_POSITION_CONTAINS) == pos disp("root contains text"); else disp("root does not contain text"); end |
deleteData |
|
getBaseURI |
The base URI of a text node is the URI of the document that owns the text node. |
getData |
|
getLength |
|
getNextSibling |
|
getNodeName | name = getNodeName(thisText) returns
'#text' . |
getNodeType |
This method provides compatibility with existing MATLAB® code that is based on the W3C XML DOM standard. For new
MATLAB code, use import matlab.io.xml.dom.* d = Document('book'); para = createElement(d,"para"); txt = createTextNode(d,"hello"); if isa(txt,'matlab.io.xml.dom.Text') fprintf('This is a text node.\n'); end |
getNodeTypeName | name = getNodeTypeName(thisText) returns
'TEXT_NODE' . |
getNodeValue |
|
getOwnerDocument |
|
getParentNode | parent = getParentNode(thisText) returns the parent node of
this text node. If this text node does not have a parent, the method returns an
empty node. |
getPreviousSibling |
|
getTextContent | getTextContent(thisText) returns the text content of this
text node as a character vector. |
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 text node to append to a document element by using the createTextNode
method of the matlab.io.xml.dom.Document
object that represents the document.
Import the matlab.io.xml.dom
package so that you do not have to use long, fully qualified class names.
import matlab.io.xml.dom.*
Create a document with a root element named employee
.
doc = Document("employee");
employeeElem = getDocumentElement(doc);
Create an element named jobtitle
.
jobtitleElem = createElement(doc,"jobtitle");
Create a text node for the jobtitle
text content and append the text note to the jobtitle
element.
textNode = createTextNode(doc,"Manager");
appendChild(jobtitleElem,textNode);
Append the jobtitle
element to the employeeElem
element.
appendChild(employeeElem,jobtitleElem);
Write the XML to a file.
xmlFileName = "employee.xml";
writer = matlab.io.xml.dom.DOMWriter;
writeToFile(writer,doc,xmlFileName);
Version History
Introduced in R2021a
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- 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)