PHP ate my XML's whitespace! I want it back!

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

     Oh, how I love SimpleXML.  Lovelovelove.
     It's not powerful, but it put about 70% of the XML pie within
easy reach of my questing, clublike fingers.  And it's got DOM...
interoperability, or something (probably not the right term) for when
I need to do more!

     One thing I'm not so fond of is... PHP eats my whitespace.  I
have a nice, human-readable list;

          <hatlike>Kermit T. Frog</hatlike>

I load this list into an XML node, make some changes, and output it
back to XML again!  Only now it usually looks thusly;

T. Frog</hatlike><headlike>Hand</headlike></thing></hatlike_things>

The parser may not care, but I care!  I want my whitespace back darn
it!  I want to be able to read the results of a XML node I transform!
There was no joyful simple way of doing this when I last checked,
uh... 12-18 months ago.  Has one emerged, in the interim?

     (Many years ago, when I used macs extensively, i have a nifty
drag-and-drop program called 'the ugly stick' I could drop PC .txt
files on.  It made them readable by fixing all the carriage-return
nonsense and turning a swarm of uneven line breaks into neat paragraph
blocks.  This is what I seek- an Ugly Stick with which to beat
outputted XML into something I can use without a script mediating for


Re: PHP ate my XML's whitespace! I want it back!


Quoted text here. Click to load it

See the UCNs on

In short: Use the DOM extension to get more control over the output


Site Timeline