matlab.io.xml.dom.Comment class
Package:matlab.io.xml.dom
评论in XML document
描述
An object of themlreportgen.io.xml.dom.Comment
class represents a comment in an XML document.
Thematlab.io.xml.dom.Comment
班级是处理
class.
Creation
Create amatlab.io.xml.dom.Comment
对象通过使用创建
方法matlab.io.xml.dom.Document
目的。
Properties
Length
—Number of characters in comment
双倍的
Number of characters in the comment, specified as a double.
属性:
GetAccess |
上市
|
SetAccess |
immutable
|
Transient |
真的
|
NonCopyable |
真的
|
TextContent
—评论的文字内容
character vector
评论的文本内容,指定为字符向量。
属性:
GetAccess |
上市
|
SetAccess |
immutable
|
Transient |
真的
|
NonCopyable |
真的
|
方法
Public Methods
附录 |
指定 |
cloneNode |
|
compareDocumentPosition |
解码返回的值,
例如: importmatlab.io.xml.dom。*d = Document("root");root = getDocumentElement(d);评论= createcomment(d,“评论的示例”);附录(root,评论);pos =比较pocumentPosition(注释,root);如果bitor(pos,comment.document_position_contains)。。。== pos disp("root contains comment");别的disp(“根不包含评论”);end |
deleteData |
|
getbaseuri |
|
GetData |
|
getLength |
|
getNextsibling |
|
getnodeName |
name = getnodeName(thiscomment) returns'#comment' 。 |
getNodeTypeName |
name = getNodeTypename(thiscomment) returns'remond_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 |
|
替换 |
指定 |
setdata |
指定 |
setNodeValue |
指定 |
setTextContent |
指定 |
分布 |
|
substringdata |
指定 |
例子
Add Comment to Document
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创建
方法的方法Document
object 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
matlab命令
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.
选择一个网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:。
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)