XML Extra content at the end of the document

后端 未结 2 657
深忆病人
深忆病人 2020-12-12 06:09

I\'m getting this error:

error on line 4 at column 1: Extra content at the end of the document

with this code:

    $this-&g         


        
相关标签:
2条回答
  • 2020-12-12 06:42

    After spending about 3 days on this very same problem, I have come to find the best and easiest way to get past this may be affffding the folling headers to the code:

    header("Content-type: text/xml");
            header( 'Content-Disposition: attachment; filename='.$_SESSION['WorkTable'].'_contacts-'.$date.'.xml');
    

    Add this to your code between this lines:

    $query = $query->result_array();
    //add it here <--
    header("Content-type: text/xml");
    
    0 讨论(0)
  • 2020-12-12 06:53

    Without seeing the text output itself, it would be impossible to know for sure, but there are a couple of things I noticed immediately:

    1. To debug this, send the header header("Content-type: text");.
    2. parseToXML is an attempt to re-invent the wheel, use htmlentities.
    3. (This and the following should be irrelevant, you should be using htmlentities) You are replacing & after replacing everything else with an entity. This means you're getting, &amp;lt; instead of &lt;.
    4. str_replace takes arrays as parameters, you would be best using them.
    0 讨论(0)
提交回复
热议问题