toString method

  1. @override
String toString({
  1. bool doubleQuotes = true,
  2. bool encodeCharacterEntities = true,
  3. String? encodeCharacters,
})
override

Returns this element as an unformatted XML string.

If doubleQuotes is true, double-quotes will be used to wrap all attribute values, otherwise single-quotes will be used.

If encodeCharacterEntities is true, text and attribute values will be parsed and have the characters included in encodeCharacters encoded as character entities.

If encodeCharacters is null, attribute values will be parsed for less-than (<), greater-than (>), ampersand (&), apostrophe or single quote (') and double-quote ("). And, XmlText nodes will be encoded for less-than (<), greater-than (>), and ampersand (&).

Note: If an element's id isn't null and possess an ID attribute, the value for id will be used over the attribute.

Implementation

@override
String toString({
  bool doubleQuotes = true,
  bool encodeCharacterEntities = true,
  String? encodeCharacters,
}) {
  var element = _buildTag(
    doubleQuotes: doubleQuotes,
    encodeCharacterEntities: encodeCharacterEntities,
    encodeCharacters: encodeCharacters,
  );

  if (children != null) {
    element += children!.write(
      encodeCharacterEntities: encodeCharacterEntities,
      encodeCharacters: encodeCharacters,
      doubleQuotes: doubleQuotes,
    );

    element += '</$name>';
  }

  return element;
}