IXMLDOMNode.parentNode (C#)
Previous | Next |
IXMLDOMNode.parentNode (C#)
The parentNode property contains the parent node of the IXMLDOMNode object.
Syntax
IXMLDOMNode = IXMLDOMNode.parentNode;
Remarks
The property is read-only. All nodes except document and attribute nodes can have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, the parent is NULL.
The value of the IXMLDOMNode object returned depends on the type of node on which the parentNode 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 parent node for that element node.
Node type | Value returned |
NODE_ATTRIBUTE NODE_DOCUMENT |
Returns NULL; these nodes do not have parents. |
NODE_COMMENT | Returns the element, entity reference, document type, or document containing the comment. |
NODE_ELEMENT | Returns the parent node of the element. If the element is the root node in the tree, the parent is the document node. If the node is the document node, parentNode is NULL. |
NODE_PROCESSING_INSTRUCTION | Returns the document or element containing the processing instruction. |
NODE_TEXT | Returns the parent element or attribute. |
Example Code
The following example creates an IXMLDOMNode object from another node object's parent.
using Microsoft.WindowsMediaServices.Interop; using interop_msxml; // Declare variables. WMSServer Server; IXMLDOMDocument Playlist; IXMLDOMNode currNode; 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 first child node of the second child node // in the root element. currNode = Playlist.documentElement.childNodes[1].childNodes[0]; // Retrieve the parent node. newNode = currNode.parentNode; } 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 |