Share via


IXMLDOMNode.lastChild (C#)

banner art

Previous Next

IXMLDOMNode.lastChild (C#)

The lastChild property returns the last child node.

Syntax

  IXMLDOMNode = IXMLDOMNode.lastChild;

Remarks

The property is read-only. If there are no children, it returns NULL.

The value of the IXMLDOMNode object returned depends on the type of node on which the lastChild property is called, as shown in the following table. For example, if the node type is NODE_ELEMENT, an IXMLDOMNode object is returned containing the last child node for that element node.

Node type Value returned
NODE_ATTRIBUTE
NODE_DOCUMENT
NODE_ELEMENT
Returns the last child node. If there are no children, it returns NULL.
NODE_COMMENT
NODE_PROCESSING_INSTRUCTION
NODE_TEXT
Returns NULL. This node type cannot have children.

Example Code

The following example creates a new IXMLDOMNode (element) object, and then inserts it before the last child of the top-level node.

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

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

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.
    newNode = Playlist.createNode(DOMNodeType.NODE_ELEMENT, "media", "");

    // Insert the new node before the last child node of the root element.
    currNode = Root.insertBefore(newNode, Root.lastChild);
}
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