douding_1073 2011-07-15 19:46
浏览 37

php为RSS feed生成xml但无法解析它,因为该文件是php

Hi Im trying to create a news feed using php. I have a php code written which connects to the database and retrieves information which is converted into XML. The file is however a .php and when I try to parse it using google reader it dosen't work because it only reads files which are XML. Here's my code:

<?php
header("Content-type: text/xml");
$dept = $_GET['dept'];
require_once ("/var/www/html/http/sass/includes/config.inc.php");
require_once ("sass_news.php");
$sassNews = paginate('sass_news', 'sass_news', $numResults, $offset, $order, $condition);
if($sassNews) {
    $xml_output = "<?xml version=\"1.0\"?>
";
    $xml_output .= "<entries>
";

        foreach($sassNews as $newsDetail){
        $xml_output .= "\t<entry>
";
        $xml_output .= "\t\t<date>" . $newsDetail->news_start_date . "</date>
";
        $xml_output .= "\t\t<text>" . $newsDetail->news_body_en . "</text>
";
        $xml_output .= "\t</entry>
";
     }

    $xml_output .= "</entries>";

    echo $xml_output;

}
?>
  • 写回答

2条回答 默认 最新

  • dongzanxun2790 2011-07-15 19:54
    关注

    Try header('Content-disposition: attachment; filename=somename.xml'); at the top of the script. However, if Google Reader is going to allow only URLS which literally end in .xml, then you'll need to reconfigure your server to treat .xml files as PHP scripts and rename this script to whatever.xml.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端