At 3am, I was pounding my head on my keyboard with this bizarre problem. The PHP code I had written was reading the XML data from the XML file but for some inexplicable reason was breaking one of the nodes in half. If it was supposed to read "the quick brown fox jumped over the lazy dog" it would instead create two nodes such as "the quick brown" and "fox jumped over the lazy dog". Maddening! So I slept. And in 5 minutes this morning, I solved the problem. I still wish I could take a pill instead of sleeping.
Update: The correction to the problem was to read the whole file instead of reading it in 4096 chunks.