I have 2 identical XML feed generators. The only difference is the customer content the feeds pull from the database. One feed pulls content of a specific customer from the database, while the other feed pulls content from all other customers.
Both feeds have been working, until now.
My feed dedicated to a specific customer is generating this error:
XML Parsing Error: no element found
Line Number 1, Column 1:
As I mentioned this has just started happening. Another funny thing is, when I swap out the customer info in the broken feed, the XML document renders correctly.
Is it possible my customer has some content in the database that is breaking my XML tags?
I'm using PHP's DOMDocument class to generate the XML files and wrapping all values with the createCDATASection() method.
In Chrome I get this error when trying to view the document
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
I've been struggling with this error all evening and have not gotten any closer to fixing the problem, but I have made a couple of very odd discoveries that make absolutely no sense to me.
Here is the loop that is generating the XML doc
while($feed_jobs->have_posts()) : $feed_jobs->the_post();
$b = $doc->createElement( "job" );
$title = $doc->createElement("title");
$b->appendChild( $title );
$company_name = "Sample Company Name";
$company = $doc->createElement("company");
$date = $doc->createElement("date");
$referencenumber = $doc->createElement("referencenumber");
$url = $doc->createElement("url");
$description = $doc->createElement("description");
$description = createCDATASection($post->post_content);
//query postmeta table for city and state// then parse it into an array
$location = get_post_meta($post->ID,'geo_address',true);
$location = explode(',',$location);
$city = $doc->createElement("city");
$state = $doc->createElement("state");
$r->appendChild( $b );
I've noticed that if I remove the "url" and "description" nodes the feed generates correctly. Similarly, if I remove "company_name", "date", and "description", I can leave the "url" node in and everything will again function properly.
Any help would be greatly appreciated. This is a very critical problem for my business.
Not sure if I'm going to get any response to this thread, but I've been working on this problem all weekend and I've found there doesn't seem do be anything suspicious with the content. I altered the script to output plain html instead of xml and everything looks fine. I've also tried playing with output buffering and that still doesn't help.
I have found though this script doesn't work on my localhost when pulling content for any of my customers. It continues to work on my production server for all but one of my customers.
It looks like you're on the right track, and have narrowed it down to the likely candidates. Unfortunately, it's just detective work to figure out what's specifically causing the issue. Though it looks, based on your troubleshooting - like it's the description that's causing you the issue. Perhaps they've changed the description - possibly a copy/paste error you can't see through the browser where it's inadvertently opening/closing a cdata element where it shouldn't?
This topic is now closed. New replies are no longer allowed.