簡體   English   中英

如何直接從數據庫保存為XML文件

[英]How to save as an XML file directly from the database

目前,我已將RSS / XML提要寫入數據庫,但我希望將這些提要公開。

例如,對於模塊A,我想它,所以你可以去feed.php?module = A,它會生成一個帶有.xml文件結尾的feed,例如feed.xml。

來自數據庫的示例XML代碼:

[?xml version="1.0" encoding="UTF-8"?]
[rss version="2.0"]
[channel]
[title]Module news for module A: D&D[/title]
[description]Desc for module here[/description]
[language]en[/language]
[item]
[title]test article[/title]
[pubDate]Tue, 20 Sep 2011 16:14:20[/pubDate]
[description]A test article would go here.[/description]
[link]http://www.google.com[/link]
[author]esujdt[/author]
[guid]http://www.google.com[/guid]
[/item]
[/channel]
[/rss]

任何幫助將非常感激。

只需發出一個header()來指定content-disposition,它允許你提供一個文件名:

header('Content-disposition: attachment; filename=feed.xml');
header('Content-type: text/xml');
header('Content-length: ' . strlen($xml));
echo $xml;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM