Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

XML DOM - Attr object


May 27, 2021 XML DOM


Table of contents


XML DOM - Attr object


The Attr object

The Attr object represents the properties of the Element object. The permissible value of a property is usually defined in DTD.

Because the Attr object is also a node, it inherits the properties and methods of the Node object. However, the property cannot have a parent node, and the property is not considered a child of the element, and for many Node properties null is returned.

Attr object properties

属性 描述
baseURI 返回属性的绝对基准 URI。
isId 如果属性是 ID 类型,则返回 true,否则返回 false。
localName 返回属性名称的本地部分。
name 返回属性的名称。
namespaceURI 返回属性的命名空间 URI。
nodeName 返回节点的名称,根据其类型。
nodeType 返回节点的类型。
nodeValue 设置或返回节点的值,根据其类型。
ownerDocument 返回属性所属的根元素(document 对象)。
ownerElement 返回属性所附属的元素节点。
prefix 设置或返回属性的命名空间前缀。
schemaTypeInfo 返回与属性相关联的类型信息。
specified 如果属性值被设置在文档中,则返回 true,如果其默认值被设置在 DTD/Schema 中,则返回 false。
textContent 设置或返回属性的文本内容。
value 设置或返回属性的值。

Related tutorials

DTD tutorial