void TiXmlElement::FormattedStreamOut(TIXML_OSTREAM * stream, int depth) const { // Adding tabs to get the proper tree format int oldDepth = depth; StreamDepth(stream, depth); // Element name (*stream) << "<" << value; // Attributes const TiXmlAttribute* attrib; for (attrib = attributeSet.First(); attrib; attrib = attrib->Next()) { (*stream) << " "; attrib->StreamOut(stream); } // There are 3 different formatting approaches: // 1) An element without children is printed as a <foo /> node // 2) An element with only a text child is printed as <foo> text </foo> // 3) An element with children is printed on multiple lines. TiXmlNode* node; if (!firstChild) { (*stream) << " />" << TIXML_ENDL; } else if (firstChild == lastChild && firstChild->ToText()) { (*stream) << ">"; firstChild->FormattedStreamOut(stream, depth + 1); (*stream) << "</" << value << ">" << TIXML_ENDL; } else { (*stream) << ">" << TIXML_ENDL; // Children depth++; for (node = firstChild; node; node=node->NextSibling()) { node->FormattedStreamOut(stream, depth); } StreamDepth(stream, oldDepth); (*stream) << "</" << value << ">" << TIXML_ENDL; } }