IXMLDOMDocument.createAttribute (C#)

banner art

Previous Next

IXMLDOMDocument.createAttribute (C#)

The createAttribute method creates a new attribute with the specified name.

Syntax

  IXMLDOMAttribute = IXMLDOMDocument
  .createAttribute(
  string strName
);

Parameters

strName

[in] string specifying the name of the new attribute object. This name is subsequently available as the new node's nodeName property.

Return Values

Returns the new IXMLDOMAttribute object.

Remarks

No data value is set for the attribute during the create operation. You can set the value by calling the setAttribute method of the element object.

The parentNode property is always set to NULL.

The nodeType property has the value NODE_ATTRIBUTE.

Example Code

The following example creates a new attribute called ID and adds it to the attributes of the IXMLDOMDocument object.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

// Declare variables.
WMSServer Server;
IXMLDOMDocument Playlist;
IXMLDOMElement Root;
IXMLDOMAttribute newAtt;
IXMLDOMNamedNodeMap namedNodeMap;

try {
    // Create a new WMSServer object.
    Server = new WMSServerClass();

    // Create a new playlist object.
    Playlist = Server.CreatePlaylist();

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

    // Retrieve the root element.
    Root = Playlist.documentElement;

    // Create a new attribute and add it 
    // to the attributes of the root element.
    newAtt = Playlist.createAttribute("ID");
    namedNodeMap = Root.attributes;
    namedNodeMap.setNamedItem(newAtt);
}
catch (Exception e) {
    // TODO: Handle exceptions.
}

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

Previous Next