DOM with SimpleXML Doesnt show the data in XML format in Browser using PHP

后端 未结 1 1065
名媛妹妹
名媛妹妹 2021-01-28 09:49

This is my PHP code to read XML from a URL using SimpleXML and DOM to change some parameters and show it on a web page

The Feed i am reading is at http://tinyurl.com/bo

相关标签:
1条回答
  • 2021-01-28 10:16

    It's a matter of the Content-Type HTTP header. The second link uses the application/xml while the first one uses php's default text/html. You can change your php script's HTTP headers with the header() function.

    header('content-type: application/xml');
    

    EDIT:

    I've been able to fetch the original input, the only the header doesn't made it work (at least in firefox), got parse error on line 48580, this is due no encoding was set to the DOMDocument object, while the original input is in utf-8. With

    $doc = new DOMDocument('1.0', 'utf-8');
    

    should work.

    0 讨论(0)
提交回复
热议问题