findById method

XmlElement? findById(
  1. String id
)

Implementation

XmlElement? findById(String id) {
  try {
    return root.descendants.whereType<XmlElement>().firstWhere(
          (e) => e.getAttribute('id') == id,
        );
  } on StateError {
    return null;
  }
}