Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -473,12 +473,32 @@ return [characters stringByXMLEscaping]; if (CDATA != nil) return [OFString stringWithFormat: @"", CDATA]; - if (comment != nil) - return [OFString stringWithFormat: @"", comment]; + if (comment != nil) { + OFString *ret; + + if (indentation > 0 && level > 0) { + char *whitespaces = [self + allocMemoryWithSize: (level * indentation) + 1]; + memset(whitespaces, ' ', level * indentation); + whitespaces[level * indentation] = 0; + + @try { + ret = [OFString + stringWithFormat: @"%s", + whitespaces, comment]; + } @finally { + [self freeMemory: whitespaces]; + } + } else + ret = [OFString stringWithFormat: @"", + comment]; + + return ret; + } pool = [[OFAutoreleasePool alloc] init]; if (parent != nil && parent->namespaces != nil) { OFEnumerator *keyEnumerator = [namespaces keyEnumerator]; @@ -615,11 +635,12 @@ if (indentation > 0) { indent = YES; for (j = 0; j < childrenCount; j++) { - if (childrenCArray[j]->name == nil) { + if (childrenCArray[j]->characters != nil || + childrenCArray[j]->CDATA != nil) { indent = NO; break; } } } else