Menu

Whitespace between attributes and elements

James
2005-07-13
2013-05-20
  • James

    James - 2005-07-13

    Hello, thanks for the awesome library!  My question is with regard to whitespace between attribute values and elements.  I found some discussion a long time ago here http://sourceforge.net/forum/forum.php?thread_id=996489&forum_id=42748 but didn't see any answer other than we'll look into it.

    I was wondering if any progress has been made, ideally I would like to open a xml file, then be able to save it out and all the whitespace and formatting would stay intact, SetCondenseWhiteSpace doesn't seem to fix this.  I can give you examples if needed.  Whitespace is VERY useful between attributes because it makes hand editing easier.

     
    • Ellers

      Ellers - 2005-07-14

      Could you post some examples?

      In my own work I can "pretty" format XML by adding whitespace before and after an element according to how nested the element is, but that will never affect the space between attributes in an element. For that you'd definitely need to modify the writing code itself (rather than just modifying the DOM at runtime), AFAIK.

      Ellers

       
    • James

      James - 2005-07-15

      i'm not sure if this will show up correctly, copy and paste the section into notepad to see what I'm saying, i used spaces instead of tabs in this example

      without spacing
      <people name="Billy Manfre" Sex="Male" Age="36" />
      <people name="Suse" Sex="Female" Age="16" />
      <people name="Johnny Bobbintosh" Sex="Male" Age="36" />
      <people name="Mark M" Sex="Male" Age="36" />
      <people name="Josh Keys" Sex="Male" Age="36" />

      with spacing
      <people name="Billy Manfre"       Sex="Male"    Age="36" />
      <people name="Suse"               Sex="Female"  Age="16" />
      <people name="Johnny Bobbintosh"  Sex="Male"    Age="36" />
      <people name="Mark M"             Sex="Male"    Age="36" />
      <people name="Josh Keys"          Sex="Male"    Age="36" />

       
    • James

      James - 2005-07-15

      well looks like it the html ate my spaces, pretend the dashes are spaces

      with spacing
      <people name="Billy Manfre" -------Sex="Male" ----Age="36" />
      <people name="Suse" ---------------Sex="Female"---Age="16" />
      <people name="Johnny Bobbintosh" --Sex="Male" ----Age="36" />
      <people name="Mark M" -------------Sex="Male" ----Age="36" />
      <people name="Josh Keys" ----------Sex="Male" ----Age="36" />

       
    • Lee Thomason

      Lee Thomason - 2005-07-24

      Yeah - tinyxml eats space in the case your are referring to.

      I understand the request - and there are a bunch of flavors of how people want XML to work - but formatting and output is a time consuming problem because everyone wants a particular style. And the value is limited since the data doesn't change, just the presentation.

      While it would be useful, addressing formatting is pretty far down on the list of enhancements for TinyXML right now.

      lee

       

Log in to post a comment.