visitElement method

  1. @override
void visitElement (
  1. XmlElement node
)
override

Visit an XmlElement node.

Implementation

@override
void visitElement(XmlElement node) {
  newLine();
  buffer.write(XmlToken.openElement);
  visit(node.name);
  writeAttributes(node);
  if (node.children.isEmpty && node.isSelfClosing) {
    buffer.write(XmlToken.closeEndElement);
  } else {
    buffer.write(XmlToken.closeElement);
    level++;
    writeChildren(node);
    level--;
    if (!node.children.every((each) => each is XmlText)) {
      newLine();
    }
    buffer.write(XmlToken.openEndElement);
    visit(node.name);
    buffer.write(XmlToken.closeElement);
  }
}