matlab.io.xml.dom.Comment Class
Namespace: matlab.io.xml.dom
Description
An object of the mlreportgen.io.xml.dom.Comment
class represents a comment
in an XML document.
The matlab.io.xml.dom.Comment
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.Comment
object by using the
createComment
method of a matlab.io.xml.dom.Document
object.
Properties
Number of characters in the comment, specified as a double.
Attributes:
GetAccess | public |
SetAccess | immutable |
Transient | true |
NonCopyable | true |
Text content of the comment, specified as a character vector.
Attributes:
GetAccess | public |
SetAccess | immutable |
Transient | true |
NonCopyable | true |
Methods
appendData |
Specify
|
cloneNode |
|
compareDocumentPosition |
To decode the returned value,
For example: import matlab.io.xml.dom.* d = Document("root"); root = getDocumentElement(d); comment = createComment(d,"Example of a comment"); appendChild(root,comment); pos = compareDocumentPosition(comment,root); if bitor(pos,comment.DOCUMENT_POSITION_CONTAINS)... == pos disp("root contains comment"); else disp("root does not contain comment"); end |
deleteData |
|
getBaseURI |
|
getData |
|
getLength |
|
getNextSibling |
|
getNodeName | name = getNodeName(thisComment) returns
'#comment' . |
getNodeTypeName | name = getNodeTypeName(thisComment) returns
'COMMENT_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 adds a comment to the root node of an XML document that represents the days of the week.
Create a matlab.io.xml.dom.Document
object with a root element named weekdays
.
import matlab.io.xml.dom.* doc = Document("weekdays"); docRootNode = getDocumentElement(doc);
Use the createComment
method of the Document
object to create a comment. Append the comment to the root element.
appendChild(docRootNode,createComment(doc,"days of the week except Saturday and Sunday"));
For each week day, Monday through Friday, create an element named day
and append the name of the day to the day
element. Append the day
elements to the root element.
weekdays = ["Mon" "Tue" "Wed" "Thu" "Fri"]; for i=1:5 dayElement = createElement(doc,"day"); appendChild(dayElement,createTextNode(doc,weekdays(i))); appendChild(docRootNode,dayElement); end
Write the document to the file weekdays.xml
;
xmlFileName = "weekdays.xml";
writer = matlab.io.xml.dom.DOMWriter;
writer.Configuration.FormatPrettyPrint = true;
writeToFile(writer,doc,xmlFileName);
Display the file contents.
type weekdays.xml;
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <weekdays> <!--days of the week except Saturday and Sunday--> <day>Mon</day> <day>Tue</day> <day>Wed</day> <day>Thu</day> <day>Fri</day> </weekdays>
The comment <!--days of the week except Saturday and Sunday-->
immediately follows the opening tag of the root element weekdays
.
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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)