Skip to content

Commit ee53abf

Browse files
committed
xmlSaveFormatFile(): indent xml properly
1 parent 56f992f commit ee53abf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

xml.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ void
129129
xml_init(const char *filename)
130130
{
131131
LIBXML_TEST_VERSION
132+
133+
/*
134+
* These two global variables have to be set before xmlReadFile()
135+
* in order for xmlSaveFormatFile() to indent properly.
136+
*/
137+
xmlKeepBlanksDefault(0);
138+
xmlIndentTreeOutput = 1;
139+
132140
ctx.filename = strdup(filename);
133141
ctx.doc = xmlReadFile(filename, NULL, 0);
134142
if (!ctx.doc) {
@@ -139,7 +147,7 @@ xml_init(const char *filename)
139147
void
140148
xml_save(void)
141149
{
142-
xmlSaveFile(ctx.filename, ctx.doc);
150+
xmlSaveFormatFile(ctx.filename, ctx.doc, 1);
143151
}
144152

145153
void

0 commit comments

Comments
 (0)