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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)