Stopping extra space in XML output

wxdqz

New Member
I'm using PHP arrays to translate XML into XHTML. But when I view the source of the outputted page from the browser, I find extra space. It has put a carriage return followed by nine single spaces after each piece of data. This is because the spaces are there in the XML file (generated from XML Notepad).

My code comes out like this:

---------< a href='http://www.webdeveloper.com/forum/archive/index.php/Ag040603.doc
---------' title='Word'>(Agenda)< /a>< /td>

(Where "-" represents a space.) Luckily it still works.

I looked at controlling whitespace but that is only between tags. I thought my routine merely took the data between each tag and output the right HTML when a certain tag is found. Now it seems to be outputting spaces from the original file as well.

I don't want to remove all carriage returns as they can be useful in outputting clear HTML code flow. But I want to remove them from occuring after each piece of data is output (because as you can see above it is breaking up lines of HTML).

Is the only way to scan the XML first and remove spaces and returns?
 
Back
Top