Xmlnode_Object GetElementNode Method

Returns the element node that is a child of the current node and has the specified element name.

…xmlnode_object.GetElementNode(element)

Prerequisites

The current node must be of type "element" or "document".

Parameters

element

An optional String expression that specifies the name of the child element to be found. If the String is omitted or empty (""), the node for the first child element is returned.

Remarks

This is a convenience method that finds a named child element node. A new XmlNode object corresponding to the element is returned.

If the element parameter is omitted or empty, the first child element of the current node is returned. If there are no child elements for the current node, a Nothing object is returned.

If the element parameter is specified but no such element is found, an exception is thrown.

The element must be an immediate child of the current node.

Examples

Dim doc As XmlDoc
Dim
root As XmlNode
Dim
elem As XmlNode
doc = New XmlDoc("my_doc")
root = doc.DocumentElement
root.AddElement("section1", "data")
elem = root.GetElementNode("section1")
Console.Writeline(elem.Name) ' Output is "section1"

See Also

XML Classes | xmlnode_object.GetAttributeNode | xmlnode_object.GetElement | xmlnode_object.SetElement