IXMLDOMNode.childNodes (C#)
Previous | Next |
IXMLDOMNode.childNodes (C#)
The childNodes property contains a list of the child nodes.
Syntax
IXMLDOMNodeList = IXMLDOMNode.childNodes;
Remarks
The property is read-only. An IXMLDOMNodeList object is returned even if there are no children of the node. In such a case, the length of the list will be set to zero. For information about valid child node types for each node, see XML DOM Enumerated Constants.
The value of the IXMLDOMNodeList object returned depends on the type of node on which the childNodes property is called, as shown in the following table. For example, if the node type is NODE_ELEMENT, an IXMLDOMNodeList object is returned containing a list of child nodes for that element node.
Node type | Value returned |
NODE_ATTRIBUTE NODE_DOCUMENT NODE_ELEMENT |
Returns an IXMLDOMNodeList object that contains a list of all child nodes for the specified node. |
NODE_COMMENT NODE_PROCESSING_INSTRUCTION NODE_TEXT |
Returns an IXMLDOMNodeList object with a length of zero. This node type cannot have children. |
Example Code
The following example uses the childNodes property (collection) to return an IXMLDOMNodeList object, and then iterates through the collection, displaying the name of each item.
using Microsoft.WindowsMediaServices.Interop; using interop_msxml; // Declare variables. WMSServer Server; IXMLDOMDocument Playlist; IXMLDOMElement Root; IXMLDOMNodeList oNodeList; 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; oNodeList = Root.childNodes; for (int i = 0; i < oNodeList.length; i++) { MessageBox.Show(oNodeList[i].nodeName.ToString()); } } 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 |