IXMLDOMNamedNodeMap.setNamedItem (Visual Basic .NET)
Previous | Next |
IXMLDOMNamedNodeMap.setNamedItem (Visual Basic .NET)
The setNamedItem method adds the supplied node to the collection.
Syntax
IXMLDOMNode = IXMLDOMNamedNodeMap .setNamedItem( newItem As IXMLDOMNode )
Parameters
newItem
[in] IXMLDOMNode object containing the attribute to be added to the collection.
Return Values
Returns the attribute added to the collection.
Remarks
If the attribute to be added to the collection has the same name as an existing attribute, the supplied attribute replaces the existing attribute. The attribute name appears in the IXMLDOMNode.nodeName property.
If the newItem node type is not NODE_ATTRIBUTE, setNamedItem returns an error. For example, it is not possible to modify entities or notations because they are read-only.
Example Code
The following example creates a new attribute and adds it to the element node using the setNamedItem method.
Imports interop_msxml Imports Microsoft.WindowsMediaServices.Interop On Error GoTo Err ' Declare variables. Dim Server As New WMSServerClass() Dim Playlist As IXMLDOMDocument Dim Elem As IXMLDOMElement Dim ChildList As IXMLDOMNodeList Dim XMLNamedNodeMap As IXMLDOMNamedNodeMap Dim NodeMedia As IXMLDOMAttribute ' Create a new playlist object. Set Playlist = Server.CreatePlaylist ' Load a playlist. Playlist.Load ("file://c:\wmpub\wmroot\simple.wsx") ' Retrieve a pointer to the root element. Elem = Playlist.documentElement ' Retrieve a list of the child nodes. ChildList = Elem.childNodes ' Retrieve the list of attributes for the first ' node in the child node list. XMLNamedNodeMap = ChildList.item(0).attributes ' Create a new attribute. NodeMedia = Playlist.createAttribute("src") ' Set the value of the new attribute. NodeMedia.value = "new_content.asf" ' Add the src attribute to the media element. XMLNamedNodeMap.setNamedItem(NodeMedia) Exit Sub Err: ' TODO: Handle errors.
Requirements
Reference: Add references to Microsoft.WindowsMediaServices and interop_msxml.
Namespace: Microsoft.WindowsMediaServices.Interop, interop_msxml.
Assembly: Microsoft.WindowsMediaServices.dll, interop_msxml.dll.
Library: WMSServerTypeLib.dll, msxml.dll.
Platform: Windows Server 2003 family, Windows Server 2008 family.
See Also
- IXMLDOMNamedNodeMap Object (Visual Basic .NET)
- IXMLDOMNode Object (Visual Basic .NET)
- XML DOM Methods (Visual Basic .NET)
Previous | Next |