I agree that a SetIndent() function is better than having a preset indent.
[mini-rant warning]
But I don't really like having the library re-write my XML when I save it. Even though indents can be useful, I'd rather stick with "minimal" behaviour, like other libs do, and just write the xml exactly how I loaded it. To get "pretty" XML I have to add in the extra text nodes myself.
But calling SetIndent() with "" does this (actually, I reckon SetWriteIndent("")) and everyone would be happy :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That one gets difficult, because there is no difference in the DOM between <a></a> and <a/>. With indenting, there is a text node effectively inserted into the tree (albeit a text node with whitespace chars).
The <a></a> is doubly tricky because one xml file might use that in one place and <a/> in another - depending on style/prefs etc. So TinyXml would need to be modified to support attributes on element nodes as it reads it, like node.writeCompact=true|false etc. I wouldn't support that because it gets away from being tiny ;)
But as an overall flag, as Lee mentioned, e.g. writeAllNodesCompactIfPossible=true, is reasonable.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Getting TinyXml to not change formatting on output is a Hard Problem. There are certainly text editors that can do this sort of thing, but it takes a lot of code.
The other option is to put in a bunch of formatting preferences (tabs, tag termination options, etc.) which would be nice. TinyXml assumes that all c-output should be friendly and all iostream output should be efficient. That's not always the best set of assumptions.
lee
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Will be very useful to implement such function as:
void SetTab(const char *p);
For example:
doc.SetTab(" "); // "\t"
it will greatly reduce weigh of the big XML files, or if someone like to use " " (2 blanks) instead of default " " (4 blanks)
I agree that a SetIndent() function is better than having a preset indent.
[mini-rant warning]
But I don't really like having the library re-write my XML when I save it. Even though indents can be useful, I'd rather stick with "minimal" behaviour, like other libs do, and just write the xml exactly how I loaded it. To get "pretty" XML I have to add in the extra text nodes myself.
But calling SetIndent() with "" does this (actually, I reckon SetWriteIndent("")) and everyone would be happy :)
"But I don't really like having the library re-write my XML when I save it." You are right, sometimes don't need autoconverting like <a></a>, to <a />
That one gets difficult, because there is no difference in the DOM between <a></a> and <a/>. With indenting, there is a text node effectively inserted into the tree (albeit a text node with whitespace chars).
The <a></a> is doubly tricky because one xml file might use that in one place and <a/> in another - depending on style/prefs etc. So TinyXml would need to be modified to support attributes on element nodes as it reads it, like node.writeCompact=true|false etc. I wouldn't support that because it gets away from being tiny ;)
But as an overall flag, as Lee mentioned, e.g. writeAllNodesCompactIfPossible=true, is reasonable.
Getting TinyXml to not change formatting on output is a Hard Problem. There are certainly text editors that can do this sort of thing, but it takes a lot of code.
The other option is to put in a bunch of formatting preferences (tabs, tag termination options, etc.) which would be nice. TinyXml assumes that all c-output should be friendly and all iostream output should be efficient. That's not always the best set of assumptions.
lee