473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

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_things>
<thing>
<hatlike>Canada</hatlike>
<headlike>Canada</headlike>
</thing>
<thing>
<hatlike>Thermosphere</hatlike>
<headlike>Mesosphere</headlike>
</thing>
<thing>
<hatlike>Kermit T. Frog</hatlike>
<headlike>Hand</headlike>
</thing>
</hatlike_things>

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

<hatlike_things><thing><hatlike>Canada</hatlike><headlike>Canada</
headlike></thing><thing><hatlike>Thermosphere</
hatlike><headlike>Mesosphere</headlike></thing><thing><hatlike>Kermit
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
me.)

-Derik
Apr 8 '08 #1
1 1560
..oO(Derik)
>I load this list into an XML node, make some changes, and output it
back to XML again! Only now it usually looks thusly;

<hatlike_things><thing><hatlike>Canada</hatlike><headlike>Canada</
headlike></thing><thing><hatlike>Thermosphere</
hatlike><headlike>Mesosphere</headlike></thing><thing><hatlike>Kermit
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?
See the UCNs on
http://www.php.net/manual/en/functio...ment-asXML.php

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

Micha
Apr 8 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ray | last post by:
I have put together some pretty simple code for adding and removing elements from an XML file, but am having a problem with toxml writing out the correct format after I have called appendChild on a...
0
by: Curtiss Howard | last post by:
I'm using Xerces 2.4.0 and I've got a schema (converted from a DTD) for my XML documents. However, Xerces will NOT ignore the whitespace between elements. These are the options I've set for the...
3
by: Celedor | last post by:
If I understand correctly, canonicalized XML is a simplified, or rather, "standardized" form of XML. It is in such a form such that two documents that are written in different ways, but contain...
4
by: Tedy | last post by:
Hi! I have XML document that looks in shortcut like this: < category > < block >
7
by: Georg J. Stach | last post by:
Hi, as mentioned above I'd like to validate a simple XML-document with a simple DTD. For this, I use Java and Xerces. But, when I have tags of this form: <tag>some characters in here</tag> ...
2
by: mmgarciaiii | last post by:
Hi everyone, I am performing an XSL transformation on IIS 5 with a dot net application and I am getting the following error message: This is an unexpected token. The expected token is...
3
by: Nick Gilbert | last post by:
Hi, I have to send an array of prices for a list of products over XML. Currently my XML data looks like this: <ArrayOfProd> <Prod Code="productcode001"> <Prices> <P F="2005-01-01"...
4
by: bkamrani | last post by:
Great guys: As a newbie, I'm trying to simply parse a xml file using minidom, but I don't know why I get some extra children(?). I don't know what is wrong in xml file, but I've tried different...
6
by: kaens | last post by:
Hey everyone, this may be a stupid question, but I noticed the following and as I'm pretty new to using xml and python, I was wondering if I could get an explanation. Let's say I write a simple...
14
by: Siv | last post by:
Hi, Just busily coding away and removed a procedure from my code and all of a sudden an error came up miles away from the location of the piece of code I removed and it relates to the XML...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.