XmlDocumentFragment.parse constructor Null safety

  1. String input,
  2. {XmlEntityMapping? entityMapping}

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

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


factory XmlDocumentFragment.parse(String input,
    {XmlEntityMapping? entityMapping}) {
  final mapping = entityMapping ?? defaultEntityMapping;
  final parser = documentFragmentParserCache[mapping];
  final result = parser.parse(input);
  if (result.isFailure) {
    final lineAndColumn =
        Token.lineAndColumnOf(result.buffer, result.position);
    throw XmlParserException(result.message,
        buffer: result.buffer,
        position: result.position,
        line: lineAndColumn[0],
        column: lineAndColumn[1]);
  return result.value;