parse function

XmlDocument parse (
  1. String input

Return an XmlDocument for the given input string, or throws an XmlParserException if the input is invalid.

For example, the following code prints Hello World:

final document = parse('<?xml?>'); print(document.rootElement.getAttribute('message'));

Note: It is the responsibility of the caller to provide a standard Dart String using the default UTF-16 encoding.


XmlDocument parse(String input) {
  final result = _parser.parse(input);
  if (result.isFailure) {
    final position = Token.lineAndColumnOf(input, result.position);
    throw XmlParserException(result.message, position[0], position[1]);
  return result.value;