matlab.io.xml.dom.attrclass
Package:matlab.io.xml.dom
attribute of XML element
描述
Amatlab.io.xml.dom.attr
object represents an attribute of an XML element.
Thematlab.io.xml.dom.attr
班级是handle
班级。
创建
创建一个matlab.io.xml.dom.attr
通过使用以下方法之一的对象:
创建一个
attr
对象通过使用createAttribute
或者createAttributeNS
methods of amatlab.io.xml.dom.document
目的。添加attr
object to amatlab.io.xml.dom..lement
对象通过使用setAttributeNode
或者setAttributeNodeNS
方法的方法元素
目的。创建并添加
attr
object to amatlab.io.xml.dom..lement
对象通过使用setAttribute
或者intattributen
方法的方法元素
目的。
特性
isid
—Whether attribute is ID attribute
false
(默认)|true
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
|
Value
—属性值
角色向量|字符串标量
此属性的值,指定为字符向量或字符串标量。
attributes:
GetAccess |
公共
|
setAccess |
公共
|
NonCopyable |
true
|
方法
公共方法
克洛诺德 |
|
compareDocumentPosition |
For example: 进口matlab.io.xml.dom.*d = Document('根');root = getDocumentElement(d); setAttribute(root,"Color",“红色的”);a = getAttributeNode(root,"Color");pos = compareDocumentPosition(a,root);ifbitor(pos,a.document_position_contains)== pos disp(“根包含颜色属性”);elsedisp("root does not contain color attribute");end |
getBaseURI |
The base URI of an attribute node is the URI of the document that owns the attribute node. |
getLength |
|
getLocalname |
|
getNextSibling |
|
getName |
name = getName(thisAttr) 将此属性的名称返回为字符向量。例如,如果此属性的名称为'颜色' ,此方法返回'颜色' 。 |
getNamespaceuri |
|
getNodeName |
name = getnodeName(thisattr) 将此属性的名称返回为字符向量。例如,如果此属性的名称为'颜色' ,此方法返回'颜色' 。 |
getNodeType |
This method provides compatibility with existing MATLAB®code that is based on the W3C XML DOM standard. 对于新的MATLAB代码,请使用 进口matlab.io.xml.dom.*d = Document('根');root = getDocumentElement(d); setAttribute(root,"Color",“红色的”);attrnode = getAttributeNode(root,"Color")ifisa(attrnode,'matlab.io.xml.dom.Attr')fprintf('This is an attribute node.\n');end |
getNodeTypename |
name = getNodeTypeName(thisAttr) returns'attribute_node' 。 |
getNodeValue |
|
getOwnerElement |
|
getOwnerDocument |
|
getParentNode |
parent = getParentNode(thisattr) 返回一个空节点,因为属性不是孩子。 |
getPrefix |
|
getPreviousSibling |
|
getschematypeinfo |
|
getSpecified |
|
getTextContent |
getTextContent(thisattr) 将此属性的值返回为字符向量。 |
getValue |
getValue(thisAttr) 将此属性的值返回为字符向量。 |
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. 在对其进行平等测试之前,将文档进行标准化,因为归一化会影响平等。 |
isID |
如果元素具有具有唯一值的ID属性,则可以使用 |
Issamenode |
|
LookupNamespaceuri |
|
lookupPrefix |
|
setNodeValue |
指定 |
setTextContent |
指定 |
设定值 |
指定 |
例子
添加一个n Attribute to an Element
This example creates and adds amatlab.io.xml.dom.attr
object 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);
添加一个Color
attribute to the帕拉
元素。
setAttribute(para,"Color",“红色的”);
将文本添加到帕拉
元素。
textnode = createTextNode(doc,“你好”);appendChild(para,textNode);
将XML写入文件。
xmlfileName ="para.xml";writer = matlab.io.xml.dom.domwriter;Writetofile(作者,Doc,XMlFileName);
创建一个attribute and Add It to an Element
此示例使用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,“红色的”);
添加Color
attribute 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
matlab命令
You clicked a link that corresponds to this MATLAB command:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。万博1manbetx
Select a Web Site
选择一个网站以获取可用的翻译内容,并查看本地事件和优惠。根据您的位置,我们建议您选择:。
You can also select a web site from the following list:
如何获得最佳网站性能
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(英语)
- United States(英语)