Menu

New function SetTab

Instructor
2005-09-27
2013-05-20
  • Instructor

    Instructor - 2005-09-27

    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)

     
    • Ellers

      Ellers - 2005-09-27

      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 :)

       
    • Instructor

      Instructor - 2005-09-28

      "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 />

       
      • Ellers

        Ellers - 2005-09-28

        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.

         
    • Lee Thomason

      Lee Thomason - 2005-09-28

      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

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.