Partager via


IXMLDOMAttribute Object (Visual Basic .NET)

The IXMLDOMAttribute object represents an attribute of the IXMLDOMElement object. For more information, see the Microsoft XML SDK 3.0 documentation available at the Microsoft Web site.

The IXMLDOMAttribute object supports the following properties and methods for describing an IXMLDOMElement IXMLDOMElement Object (Visual Basic .NET).

Property

Description

attributes

Contains the list of attributes for this node. Read-only.

childNodes

Contains a list of the children (for nodes that can have children). Read-only.

firstChild

Contains the first child of this node. Read-only.

lastChild

Contains the last child of this node. Read-only.

name

Contains the attribute name. Read-only.

nextSibling

Contains the next sibling of this node in the parent's child list. Read-only.

nodeName

Contains the qualified name of the element, attribute, or entity reference, or a fixed string for other node types. Read-only.

nodeType

Specifies the XML DOM node type, which determines valid values and whether the node can have child nodes. Read-only.

nodeTypeString*

Contains the node type in string form. Read-only.

nodeValue

Contains the text associated with the node. Read/write.

ownerDocument

Returns the root of the document that contains this node. Read-only.

parentNode

Contains the parent node (for nodes that can have parents). Read-only.

previousSibling

Contains the left sibling of this node. Read-only.

value

Contains the attribute value. Read/write.

* Denotes an extension to the W3C DOM.

Method

Description

appendChild

Appends the supplied new child as the last child of this node.

cloneNode

Creates a new node that is an exact clone of this node.

hasChildNodes

Returns a Boolean value indicating whether this node has children.

insertBefore

Inserts a child node to the left of the specified node or at the end of the list.

removeChild

Removes the specified child node from the list of children and returns it.

replaceChild

Returns the specified old child node and replaces it with the supplied new child node.

Note

   For detailed information about using the C++ programming language to access the IXMLDOMAttribute object, see the IXMLDOMAttributeIXMLDOMAttribute Interface.

Remarks

In XML, the value of an attribute is represented by the child nodes of the attribute node because the value can contain entity references. Thus attributes that contain entity references will have a child list containing both text nodes and entity reference nodes. In addition, because the attribute type might be unknown, there are no tokenized attribute values.

IXMLDOMAttribute objects inherit from the IXMLDOMNodeIXMLDOMNode Object (Visual Basic .NET), but are not actually child nodes of the element and are not considered part of the document tree. Attributes are considered to be members of their associated elements, rather than independent and separate. Thus, the object’s parentNode, previousSibling, and nextSibling properties have the value NULL.

Example

The following example creates an IXMLDOMAttribute object from the first attribute of the root element and displays the object's attribute value.

Imports interop_msxml
Imports Microsoft.WindowsMediaServices.Interop

On Error GoTo Err

' Declare variables.
Dim Server As New WMSServerClass()
Dim Playlist As IXMLDOMDocument
Dim root As IXMLDOMElement
Dim objDOMatt As IXMLDOMAttribute

' Create a new playlist object.
Set Playlist = Server.CreatePlaylist

' Load a sample playlist file.
Playlist.Load ("file://c:\wmpub\wmroot\simple.wsx")

' Retrieve the root element.
Set root = Playlist.documentElement

' Create an IXMLDOMAttribute object and display
' the attribute value of the first item in
' the first child node.
Set objDOMatt = root.firstChild.Attributes.Item(0)
MsgBox (objDOMatt.Value)
Exit Sub

Err:
' TODO: Handle errors.

See Also

Reference

IXMLDOMElement Object (Visual Basic .NET)