parseViewFile static method

ParseResult parseViewFile(
  1. String xmlContent
)

Parse a full views.xml file — returns the first view found.

Implementation

static ParseResult parseViewFile(String xmlContent) {
  try {
    final doc = xml.XmlDocument.parse(xmlContent);
    final records = doc.findAllElements('record');

    if (records.isEmpty) {
      return ParseResult.failure('No <record> elements found in the XML.');
    }

    final record = records.first;
    return _parseRecord(record);
  } on xml.XmlParserException catch (e) {
    return ParseResult.failure('XML parse error at line ${e.position}: ${e.message}');
  } catch (e) {
    return ParseResult.failure('Unexpected error: $e');
  }
}