xml method

void xml(
  1. String input, {
  2. XmlEntityMapping? entityMapping,
})

Adds a raw XML string. The string will be parsed as XmlDocumentFragment and throws an XmlParserException if the input is invalid.

To generate a bookshelf element with two predefined book elements, one would write:

builder.element('bookshelf', nest: () {
  builder.xml('<book><title>Growing a Language</title></book>');
  builder.xml('<book><title>Learning XML</title></book>');
});

Implementation

void xml(String input, {XmlEntityMapping? entityMapping}) {
  final fragment =
      XmlDocumentFragment.parse(input, entityMapping: entityMapping);
  _stack.last.children.add(fragment);
}