Share via


IXMLDOMNode.appendChild (C#)

banner art

Previous Next

IXMLDOMNode.appendChild (C#)

The appendChild method appends the supplied new child as the last child of the node.

Syntax

  IXMLDOMNode = IXMLDOMNode.appendChild(
  object objnewChild
);

Parameters

newChild

[in] object containing the new child node to be appended at the end of the list of children belonging to this node.

Return Values

Returns the new child node appended to the list.

Remarks

If newChild has an existing parent, the node is automatically removed from that parent before being inserted into its new location.

When inserting a node tree under another node that has a different owner document, the ownerDocument property for each inserted node is changed to match the owner document of its new parent.

When moving a node tree to another document, the content of all entity reference nodes contained therein is updated to conform to the new document. If the new document does not declare an entity that was moved into it, the entity reference will have no children, and the old content is removed. Existing references to nodes under the entity reference are still valid, but the node whose parent previously was the entity reference now has a null parent.

This is equivalent to calling insertBefore (newChild, NULL). For more information, see IXMLDOMNode.insertBefore.

Example Code

The following example creates a new IXMLDOMNode object, and then uses the appendChild method to append it to the document's list of children.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

// Declare variables.
WMSServer Server;
IXMLDOMDocument Playlist;
IXMLDOMElement Root;
IXMLDOMNode newNode;

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 node and append it as a child node of 
    // the root element.
    newNode = Playlist.createNode(DOMNodeType.NODE_ELEMENT, "media", "");
    Root.appendChild(newNode);
}
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