XmlDocument.parse constructor
XmlDocument.parse(
- String input, {
- XmlEntityMapping? entityMapping,
Returns an XmlDocument for the given input string, or throws an
XmlParserException or XmlTagException if the input is invalid.
For example, the following code prints Hello World:
final document = new XmlDocument.parse('<?xml?><root message="Hello World" />');
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.
Implementation
factory XmlDocument.parse(String input, {XmlEntityMapping? entityMapping}) {
final events = parseEvents(
input,
entityMapping: entityMapping,
validateNesting: true,
validateDocument: true,
);
return XmlDocument(const XmlNodeDecoder().convertIterable(events));
}