nthChild method

XmlElement? nthChild(
  1. int index
)

Returns the nth XmlElement found in children.

index must not be null and must be >= 0.

Returns null if one isn't found.

Implementation

XmlElement? nthChild(int index) {
  assert(index >= 0);
  if (children == null) return null;
  var childCount = 0;
  for (var child in children!) {
    if (child is XmlElement) {
      if (index == childCount) {
        return child;
      } else {
        childCount++;
      }
    }
  }
  return null;
}