root property

XmlElement? root

The root level element.

In a valid XML document, all elements besides the root element are nested within the root element.

Implementation

XmlElement? get root => children.cast<XmlNode?>().firstWhere(
      (node) => node.runtimeType == XmlElement,
      orElse: () => null,
    ) as XmlElement?;