• I have 2 custom XML feeds I’ve built using the DOMDocument class. The code is identical, apart from the users’ content they generate. One feed pulls a custom post type from a specific user, while the other feed pulls the same post type from all other users.

    They’ve both been working as designed until recently. Actually, one is still working, the feed that generates content from the single user is the one that is broke. It generates this error:

    XML Parsing Error: no element found
    Location: [url]https://www.mydomain/indeed-general-xml-generator/[/url]
    Line Number 1, Column 1:

    Being the only difference between these scripts is the content the pull from the database, I’m wondering if it is the data itself that screwing up my feed. Only thing is, I’m wrapping everything the createCDATASection() method, so this should be preventing something like this from happening.

    Here’s the loop that generates the XML document:

    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;

    Strange thing is, if I remove the “url” node and the “content” node the feed generates without error.
    Even more strange, if I leave the the “url” node as-is and remove the “description” node as well as the “date” and “company” nodes everything generates without error again.

    This has been driving me crazy all night. Please help!

Viewing 1 replies (of 1 total)
  • Thread Starter bbuster79

    (@bbuster79)

    Been struggling with this problem all weekend.

    I’ve verified there’s nothing weird in the content that could be breaking my tree structure.

    I’ve even tried using ob_start() at the beginning of the file then flushing the output after the script runs.

    After all the searches I’ve ran, I can’t find another single person to encounter this problem. The most similar problems are people with ALL broken RSS feeds. Most my feeds work. It’s just this one single feed that’s causing a problem…

Viewing 1 replies (of 1 total)
  • The topic ‘Irratic XML Feed Behavior!!!’ is closed to new replies.