NerdyHearn
Home
Blog

Contact
Mailing List

Software

Active Directory Products
Object Compare
Permission Compare

IPhone Products
Calls To Calendar
SMS To CSV
SMS To Gmail
Voicemail To Gmail

Sites
DocuTerminal
How Long For Me
My Music To Me
SaveMySerials
TypeCount

Blog
Twitter

NerdyHearn - Blog


<< Back To All Blogs

PHP and XML: Be very aware of your spacing

Saturday, March 22nd, 2008

I have been working on an XML API for a project that I am working on and was consistently receiving invalid XML because the first line of my XML document contained a space: hence it was not valid XML.

After looking around on the web I found nothing of relevance to me... most of the people that were having this issue were using an open source CMS, which didn't help me because I have my own internally-written system that I use.

After going through a TON of code, I found that 2 of my files that were being recursively included had an extra newline at the end of the file. I have a large set of classes and functions that are included globally on all my sites to make things much easier on me, and this newline was being propagated into my XML file when I included these files at the top of my XML document for output.

To make a long story short... do not leave extra new lines in any files you will be including, either at the beginning or the end of the file.

Continuing on...

Tom out.

Comments

Currently no comments.

Add A Comment

Name:


URL:


Email Address: (not public, used to send notifications on further comments)


Comments:



Enter the text above, except for the 1st and last character:


NerdyHearn - Latest tech news relating to C#, ASP.NET, SharePoint, PHP, general development, and more. DocuTerminal - Online Filing Cabinet solution. Scan, search and archive your paper documents. SaveMySerials - Protect yourself from theft, fire, natural disasters and more by recording your serial numbers My Music To Me - Stream your subsonic music collection to your Sonos wireless system TypeCount - Count how often you type across different computers! ServrTrackr - Monitor your SSL certificates, website uptime, and DNS configurations