Added SetForceCompactMode() for overriding the compact setting on a per-node level. All sub-nodes will be printed compact as well.
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index cb26e00..91f4011 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -580,7 +580,8 @@
_parent( 0 ),
_firstChild( 0 ), _lastChild( 0 ),
_prev( 0 ), _next( 0 ),
- _memPool( 0 )
+ _memPool( 0 ),
+ _forceCompactMode( false )
{
}
@@ -1945,17 +1946,17 @@
}
-void XMLPrinter::OpenElement( const char* name )
+void XMLPrinter::OpenElement( const char* name, bool compactMode )
{
if ( _elementJustOpened ) {
SealElement();
}
_stack.Push( name );
- if ( _textDepth < 0 && !_firstElement && !_compactMode ) {
+ if ( _textDepth < 0 && !_firstElement && !compactMode ) {
Print( "\n" );
}
- if ( !_compactMode ) {
+ if ( !compactMode ) {
PrintSpace( _depth );
}
@@ -2151,7 +2152,7 @@
bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )
{
- OpenElement( element.Name() );
+ OpenElement( element.Name(), _compactMode ? true : element.Parent()->GetForceCompactMode() );
while ( attribute ) {
PushAttribute( attribute->Name(), attribute->Value() );
attribute = attribute->Next();