当前位置: 首页 > 网络学院 > XML相关教程 > XML DOM > DOM Attribute
The Attr object represents an attribute of an Element object. The allowable values for attributes are usually defined in a DTD.
Attr对象表示一个元素对象的一个属性。属性的容许值通常是在DTD中定义的。
Because the Attr object is also a Node, it inherits the Node object's properties and methods. However, an attribute does not have a parent node and is not considered to be a child node of an element, and will return null for many of the Node properties.
因为Attr对象也是一个节点,因此,它继承了节点对象的属性和方法。然而,属性并不包含父节点,并且,它也不是一个元素的子节点,对于许多节点对象的属性来说都将返回null(空值)。
IE: Internet Explorer, F: Firefox[火狐], O: Opera, W3C: World Wide Web Consortium (Internet Standard) | 万维网联盟(国际标准)
Attr Object Properties
Attr 对象属性
Property 属性 | Description 描述 | IE | F | O | W3C |
---|---|---|---|---|---|
baseURI | Returns the absolute base URI of the attribute 返回属性的基准URI | No | 1 | No | Yes |
isId | Returns true if the attribute is known to be of type ID, otherwise it returns false 如果一个属性是已知的ID类型,则返回true(如:包含其主体元素的标志符),否则返回false | No | No | No | Yes |
localName | Returns the local part of the name of the attribute 返回属性的本地名称 | No | 1 | 9 | Yes |
name | Returns the name of the attribute 返回属性名称 | 5 | 1 | 9 | Yes |
namespaceURI | Returns the namespace URI of the attribute 设置或返回一个属性的命名空间URI | No | 1 | 9 | Yes |
nodeName | Returns the name of the node, depending on its type 返回指定类型所对应的节点名称 | 5 | 1 | 9 | Yes |
nodeType | Returns the type of the node 返回一个节点的类型 | 5 | 1 | 9 | Yes |
nodeValue | Sets or returns the value of the node, depending on its type 设置或返回指定的类型所对应的节点值 | 5 | 1 | 9 | Yes |
ownerDocument | Returns the root element (document object) for an attribute 返回一个节点的根元素(文档对象) | 5 | 1 | 9 | Yes |
ownerElement | Returns the element node the attribute is attached to 返回指定属性所附属的元素节点 | No | 1 | 9 | Yes |
prefix | Sets or returns the namespace prefix of the attribute 设置或返回一个属性的命名空间前缀 | No | 1 | 9 | Yes |
schemaTypeInfo | Returns the type information associated with this attribute 返回与属性相关的类型信息 | No | No | No | Yes |
specified | Returns true if the attribute value is set in the document, and false if it's a default value in a DTD/Schema. 如果属性值已在文档中设置,则返回true;如果属性值是DTD/Schema中的默认值,则返回false | 5 | 1 | 9 | Yes |
textContent | Sets or returns the textual content of an attribute 设置或返回一个属性的文本内容 | No | 1 | 9 | Yes |
text | Returns the text of the attribute. IE-only property 返回一个属性的文本。仅IE支持 | 5 | No | No | No |
value | Sets or returns the value of the attribute 返回一个属性值。 | 5 | 1 | 9 | Yes |
xml | Returns the XML of the attribute. IE-only property 返回一个属性的XML。仅IE支持 | 5 | No | No | No |