主要内容

matlab.io.xml.dom.attrclass

Package:matlab.io.xml.dom

attribute of XML element

描述

Amatlab.io.xml.dom.attrobject represents an attribute of an XML element.

Thematlab.io.xml.dom.attr班级是handle班级。

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

有关类属性的信息,请参阅Class Attributes

创建

创建一个matlab.io.xml.dom.attr通过使用以下方法之一的对象:

  • 创建一个attr对象通过使用createAttribute或者createAttributeNSmethods of amatlab.io.xml.dom.document目的。添加attrobject to amatlab.io.xml.dom..lement对象通过使用setAttributeNode或者setAttributeNodeNS方法的方法元素目的。

  • 创建并添加attrobject to amatlab.io.xml.dom..lement对象通过使用setAttribute或者intattributen方法的方法元素目的。

特性

展开全部

Whether this attribute is an ID attribute, specified astrue或者false

如果元素具有具有唯一值的ID属性,则可以使用getElementById方法的方法document to access the element.

attributes:

GetAccess
公共
setAccess
不变
Transient
true
NonCopyable
true

此属性的名称,指定为字符向量。

attributes:

GetAccess
公共
setAccess
不变
Transient
true
NonCopyable
true

此属性的值,指定为字符向量或字符串标量。

attributes:

GetAccess
公共
setAccess
公共
NonCopyable
true

方法

展开全部

例子

collapse all

This example creates and adds amatlab.io.xml.dom.attrobject to amatlab.io.xml.dom..lement对象通过使用setAttribute方法的方法元素目的。

Import thematlab.io.xml.dom巴勒斯坦权力机构ckage so that you do not have to use long, fully qualified class names.

进口matlab.io.xml.dom.*

用根元素创建文档帕拉

doc = Document("para");帕拉= getDocumentElement(doc);

添加一个Colorattribute to the帕拉元素。

setAttribute(para,"Color",“红色的”);

将文本添加到帕拉元素。

textnode = createTextNode(doc,“你好”);appendChild(para,textNode);

将XML写入文件。

xmlfileName ="para.xml";writer = matlab.io.xml.dom.domwriter;Writetofile(作者,Doc,XMlFileName);

此示例使用createAttribute所有者文档的方法,并将属性添加到元素中setAttributeNode方法的方法元素。

Import thematlab.io.xml.dom巴勒斯坦权力机构ckage so that you do not have to use long, fully qualified class names.

进口matlab.io.xml.dom.*

用根元素创建文档帕拉

doc = Document("para");帕拉= getDocumentElement(doc);

创建一个attributeColor并设置属性值

attrObj = createAttribute(doc,"Color");setValue(attrobj,“红色的”);

添加Colorattribute to the帕拉元素。

setAttributeNode(para,attrObj);

创建一个text node and add it to the帕拉元素。

textnode = createTextNode(doc,“你好”);appendChild(para,textNode);

将XML写入文件。

xmlfileName ="para.xml";writer = matlab.io.xml.dom.domwriter;Writetofile(作者,Doc,XMlFileName);

版本;n History

Introduced in R2021a