如何从rss feed中为我的XML文件添加空格

时间:2014-09-11 18:01:02

标签: php html xml rss

您好我的RSS页面

中有以下代码
$rss_txt .= '<item>';
$rss_txt .= '<title>' .$row['created_at']. '</title>';
$rss_txt .= '<link>http://localhost/report_profile.php?id='.$id.'</link>';
$rss_txt .= '<description>' .$row['title'].$row['area']. '</description>';
$rss_txt .= '</item>';

我想在$row['area']之后包含另一个变量$row['user_id'],但是xml文件在没有空格的情况下打印它们并且非常清楚地阅读

1 个答案:

答案 0 :(得分:0)

您的问题有点难以理解,但根据@ 1nflktd的评论,如果它是您想要的简单空间,我会建议这样的事情:

$rss_txt .= '<item>';
$rss_txt .= '<title>' .$row['created_at']. '</title>';
$rss_txt .= '<link>http://localhost/report_profile.php?id='.$id.'</link>';
$rss_txt .= '<description>' . $row['title'] . $row['area'] . ' ' . $row['user_id'] . '</description>';
$rss_txt .= '</item>';

如果您想添加空格以外的其他内容,我建议您只需在引号之间添加您喜欢的文字($ row ['user_id']和$ row ['user_id']之间):

$rss_txt .= '<item>';
$rss_txt .= '<title>' .$row['created_at']. '</title>';
$rss_txt .= '<link>http://localhost/report_profile.php?id='.$id.'</link>';
$rss_txt .= '<description>' . $row['title'] . $row['area'] . 'YOUR TEXT GOES HERE!' . $row['user_id'] . '</description>';
$rss_txt .= '</item>';