#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,688
    Rep Power
    171

    Keeping whitespaces in the XML


    I am trying to keep the whitespaces and I thought xml:space="preserve" does it but it doesn't!
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <root xml:space="preserve">
    	<things>      Lots of          whitespace
    
    and new linee</things>
    </root>
    What should I do to see these whitespaces in xml?
    Thanks
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,295
    Rep Power
    9400
    Understanding xml:space. It preserves whitespace-only nodes, not all whitespace in general. (And only if the reader supports the attribute.)

    How are you rendering the data?
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,688
    Rep Power
    171
    Originally Posted by requinix
    Understanding xml:space. It preserves whitespace-only nodes, not all whitespace in general. (And only if the reader supports the attribute.)

    How are you rendering the data?
    Firefox. The source looks ok.
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,295
    Rep Power
    9400
    The source has all the whitespace?

    Then this is the normal "HTML collapses all whitespace to a single space" problem. You can use CSS, a <pre>, or &amp;#38;nbsp; entities.
  8. #5
  9. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,688
    Rep Power
    171
    Thanks. While I got you here, instead of making more threads I ask a questions about namespace URI identifire.

    Is this true or false:

    The URI does not neccessarily exist! It is only a string that may not even exist.

    In the example below, hs could be equal to anything.
    Code:
    xmlns:hs="http://www.w3.org/1999/xhtml"
    Cheers

IMN logo majestic logo threadwatch logo seochat tools logo