主要内容

matlab.io.xml.dom.Comment class

Package:matlab.io.xml.dom

评论in XML document

描述

An object of themlreportgen.io.xml.dom.Commentclass represents a comment in an XML document.

Thematlab.io.xml.dom.Comment班级是处理class.

类属性

ConstructOnLoad
真的
HandleCompatible
真的

For information on class attributes, see类属性

Creation

Create amatlab.io.xml.dom.Comment对象通过使用创建方法matlab.io.xml.dom.Document目的。

Properties

展开全部

Number of characters in the comment, specified as a double.

属性:

GetAccess
上市
SetAccess
immutable
Transient
真的
NonCopyable
真的

评论的文本内容,指定为字符向量。

属性:

GetAccess
上市
SetAccess
immutable
Transient
真的
NonCopyable
真的

方法

展开全部

例子

全部收缩

This example adds a comment to the root node of an XML document that represents the days of the week.

Create amatlab.io.xml.dom.Document带有根元素的对象weekdays

importmatlab.io.xml.dom。*doc = Document(“工作日”);docRootNode = getDocumentElement(doc);

Use the创建方法的方法Documentobject to create a comment. Append the comment to the root element.

appendChild(docRootNode,createComment(doc,“一周中的几天,星期六和周日除外”);

For each week day, Monday through Friday, create an element named并将一天的名称附加到元素。附加elements to the root element.

weekdays = [“蒙”“星期二”"Wed""Thu"“星期五”];fori=1:5 dayElement = createElement(doc,“天”);appendChild(dayElement,createTextNode(doc,weekdays(i))); appendChild(docRootNode,dayElement);end

Write the document to the fileweekdays.xml;

xmlFileName ="weekdays.xml"; writer = matlab.io.xml.dom.DOMWriter; writer.Configuration.FormatPrettyPrint = true; writeToFile(writer,doc,xmlFileName);

Display the file contents.

typeweekdays.xml;
<?xml版本=“ 1.0” encoding =“ utf-8” standalone =“ no”?>  <! - 周六和周日以外的日子 - >  mon  星期二  wed   thu   fri   

评论<! - 周六和周日以外的一周中的几天 - >immediately follows the opening tag of the root elementweekdays

Version History

在R2021a中引入