SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML Generating Script Suddenly Not Working... Database Content Issue???

    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:

    Code PHP:
    XML Parsing Error: no element found
    Location: [url]http://www.mydomain/indeed-general-xml-generator/[/url]
    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.

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

    PHP Code:
    while($feed_jobs->have_posts()) : $feed_jobs->the_post();    

        
    $b $doc->createElement"job" );

        
    $title $doc->createElement("title");    
        
    $title->appendChild($doc->createCDATASection$post->post_title));
        
    $b->appendChild$title );

        
    $company_name "Sample Company Name";
        
    $company $doc->createElement("company");
        
    $company->appendChild($doc->createCDATASection($company_name));
        
    $b->appendChild($company); 

        
    $date $doc->createElement("date");
        
    $date->appendChild($doc->createCDATASection($post->post_date));
        
    $b->appendChild($date);

        
    $referencenumber $doc->createElement("referencenumber");
        
    $referencenumber->appendChild($doc->createCDATASection($post->ID));
        
    $b->appendChild($referencenumber);
        
        
    $url $doc->createElement("url");
        
    $url->appendChild($doc->createCDATASection($post->guid));
        
    $b->appendChild($url);

        
    $description $doc->createElement("description");
        
    $description createCDATASection($post->post_content);
        
    $description->appendChild($description);
        
    $b->appendChild($description);

        
    //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");
        
    $city->appendChild($doc->createCDATASection($location[0]));
        
    $b->appendChild($city);

        
    $state $doc->createElement("state");
        
    $state->appendChild($doc->createCDATASection($location[1]));
        
    $b->appendChild($state);

        
    $r->appendChild$b );     

    endwhile; 
    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.

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,283
    Mentioned
    121 Post(s)
    Tagged
    1 Thread(s)
    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?
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •