2010-10-24 54 views
6

我對rss提要很陌生,但我可以使用PHP動態創建提要,並且工作效果很好。我的問題是偶爾飼料沒有任何物品(我將飼料的年齡限制在60天,有時候沒有發生任何事情)。如何製作一個「空的」RSS訂閱

我希望發生的事情是,我只是在我的xml頁面中沒有任何<item> s。然而,當我這樣做的時候,閱讀器(至少是Google的閱讀器)看起來有點麻煩。儘管XML仍然正確地包含了Feed的名稱,但它沒有標題顯示。

我發現迄今爲止解決這個問題的唯一方法是放入一個虛擬物品,簡單地說就是<item><title></title></item>。然後我的Google閱讀器正確地找到了Feed的名稱,它看起來像一個空白的Feed。

看來這是一個可能不正確的hokey解決方案。

是否有一些標準方法來處理空的提要的XML演示文稿?

編輯:下面是空的飼料是什麼樣子

<?xml version="1.0" encoding="utf-8"?> <rss version="2.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/" 
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" 
xmlns:admin="http://webns.net/mvcb/" 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
xmlns:content="http://purl.org/rss/1.0/modules/content/"> 

<channel> 

<title>News at Example</title> 

<link>http://www.example.com/feed/sample-reviews</link> 
<description>Latest Additions to the Sample Category</description> 
<dc:language>en-us</dc:language> 
<dc:creator>Contact Example through our "contact us" page</dc:creator> 

<dc:rights>Copyright 2010 Example Technologies Inc.</dc:rights> 
<admin:generatorAgent rdf:resource="http://www.codeigniter.com/" /> 

     <item><title></title></item> 

</channel></rss> 
+2

聽起來像一個錯誤。 「」較少的Feed沒有任何問題。 – bobince 2010-10-24 16:28:26

+0

您可以展示您的Feed的完整示例嗎? – 2010-10-24 16:31:46

+0

我已經添加了。如果沒有那個空白的標記,那麼Google閱讀器由於某些原因不會收到Feed的主標題。有了它,它可以正常工作。它也適用於實際項目。只要沒有物品,我就會遇到問題。 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/478053/">neomech</a></span> <span>2010-10-24 17:21:47</span> </small> </span> </p> </div> </div> </div> </div> </div> </article> </div> <div class="answer-title"> <span class="text-logo margin-top-sm">A</span> <h2 class="title h4">回答</h2> </div> <div class="item-description text-md markdown-body margin-bottom-40 voidso"> <article class="board-top-1 padding-top-10"> <div class="post-col vote-info"> <span class="count">5<i class="fa fa-thumbs-up"></i></span> <i class="fa fa-check fa-2x"></i> </div> <div class="post-offset"> <div class="answer fmt"> <p>空飼料是飼料外殼(將XML的東西一般)沒有任何項目。機箱必須仍然有效,因爲它是有效的提要。</p> <p>從<a href="http://cyber.law.harvard.edu/rss/rss.html#hrelementsOfLtitemgt" rel="nofollow noreferrer">RSS 2.0 Specification</a>,而從2003年:</p> <blockquote> <blockquote> <p>通道可以包含任意數量<項目> S的</p> </blockquote> </blockquote> <p>然而,至少從<a href="http://www.thearchitect.co.uk/schemas/rss-2_0.xsd" rel="nofollow noreferrer">one RSS XSD</a>我們可以看到,它不是尊敬的開發人員知道:</p> <pre> <xs:element name="item" type="RssItem" minOccurs="1" maxOccurs="unbounded"> <!-- HACK: According to the RSS 2.0 spec, it should strictly be possible to have zero item elements, but this makes the schema non-deterministic with regard to extensibility elements so for the moment we undid bug-fix 10231 and set minOccurs=1 to work around this problem. --> </xs:element> </pre> <p>在不同的客戶端嘗試您的飼料。也許這只是谷歌實施的一個怪癖。因人而異。</p> <p>快樂編碼。</p> <p><strong>編輯:</strong>爲了好玩,請看SO問題:<a href="https://stackoverflow.com/questions/1650290/where-i-can-find-the-official-xsd-schema-for-rss-2-0">Where I can find the official XSD schema for RSS 2.0?</a>。實際上,這是相當容易的 -/</p> </div> <div class="post-info"> <div class="post-meta row"> <p class="text-secondary col-lg-6"> <span class="source"> <a rel="noopener" target="_blank" href="https://stackoverflow.com/q/4009145">來源</a> </span> </p> <p class="text-secondary col-lg-6"> <span class="float-right date"> <span>2010-10-24 16:31:26</span> </p> <p class="col-12"></p> <p class="col-12"></p></div> </div> <!-- comments --> <div class="comments"> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+0</span></div> <div class="col-lg-11"> <p class="commenttext">我在網上看到過一些關於設置某種「默認」項目的討論,這些項目表示目前沒有供稿項目。建立一個像沒有任何問題一樣的項目是否有意義? – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/478053/">neomech</a></span> <span>2010-10-24 17:04:47</span> </small> </span> </p> </div> </div> </div> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+0</span></div> <div class="col-lg-11"> <p class="commenttext">@neomech爲給定客戶使用任何[最佳]作品。快樂的編碼。 – <span class="text-secondary"> <small> <span>2010-10-24 20:45:53</span> </small> </span> </p> </div> </div> </div> </div> </div> </article> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1038284119" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <article class="board-top-1 padding-top-10"> <div class="post-col vote-info"> <span class="count">10<i class="fa fa-thumbs-up"></i></span> </div> <div class="post-offset"> <div class="answer fmt"> <p>具有零項的提要完全有效。如果谷歌閱讀器沒有正確處理,應該將它作爲錯誤報告給他們,他們應該修復它。</p> </div> <div class="post-info"> <div class="post-meta row"> <p class="text-secondary col-lg-6"> <span class="source"> <a rel="noopener" target="_blank" href="https://stackoverflow.com/q/4009177">來源</a> </span> </p> <p class="text-secondary col-lg-6"> <span class="float-right date"> <span>2010-10-24 16:36:19</span> </p> <p class="col-12"></p> <p class="col-12"></p></div> </div> <!-- comments --> <div class="comments"> <div itemprop="comment" class="post-comment"> <div class="row"> <div class="col-lg-1"><span class="text-secondary">+0</span></div> <div class="col-lg-11"> <p class="commenttext">我同意這一點。也就是說,很多人使用谷歌閱讀器(包括我自己在內),同時我希望我的代碼能正常工作,這樣我所有使用Google的用戶至少可以看到他們應該做什麼。聽起來像是有一種空的飼料「黑客」是要走的路。 – <span class="text-secondary"> <small> <a rel="noopener" target="_blank" href="https://stackoverflow.com/users/478053/">neomech</a></span> <span>2010-10-24 17:06:00</span> </small> </span> </p> </div> </div> </div> </div> </div> </article> </div> <div class="clearfix"> </div> <div class="relative-box"> <div class="relative">相關問題</div> <ul class="relative_list"> <li> 1. <a href="http://hk.uwenku.com/question/p-tlqcnekh-bhr.html" target="_blank" title="製作一個RSS訂閱點擊"> 製作一個RSS訂閱點擊 </a> </li> <li> 2. <a href="http://hk.uwenku.com/question/p-eihbcspi-bav.html" target="_blank" title="點擊一個DIV訂閱RSS訂閱"> 點擊一個DIV訂閱RSS訂閱 </a> </li> <li> 3. <a href="http://hk.uwenku.com/question/p-gffxxohl-rd.html" target="_blank" title="建立一個RSS訂閱"> 建立一個RSS訂閱 </a> </li> <li> 4. <a href="http://hk.uwenku.com/question/p-dhdocchj-bhg.html" target="_blank" title="製作iTunes的Podcast RSS訂閱"> 製作iTunes的Podcast RSS訂閱 </a> </li> <li> 5. <a href="http://hk.uwenku.com/question/p-tzlddcjy-wk.html" target="_blank" title="如何在RSS訂閱"> 如何在RSS訂閱 </a> </li> <li> 6. <a href="http://hk.uwenku.com/question/p-wsoesbtm-ue.html" target="_blank" title="翻閱RSS訂閱"> 翻閱RSS訂閱 </a> </li> <li> 7. <a href="http://hk.uwenku.com/question/p-dyvyasqi-tn.html" target="_blank" title="主持一個動態的RSS訂閱"> 主持一個動態的RSS訂閱 </a> </li> <li> 8. <a href="http://hk.uwenku.com/question/p-mhifflve-bey.html" target="_blank" title="RSS訂閱LINQ"> RSS訂閱LINQ </a> </li> <li> 9. <a href="http://hk.uwenku.com/question/p-hmhwcwzz-bea.html" target="_blank" title="訂閱RSS源"> 訂閱RSS源 </a> </li> <li> 10. <a href="http://hk.uwenku.com/question/p-nycfgsjs-bns.html" target="_blank" title="ASP.Net RSS訂閱"> ASP.Net RSS訂閱 </a> </li> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-6208739752673518" data-ad-slot="4606349252"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <li> 11. <a href="http://hk.uwenku.com/question/p-xhjsbvzx-bnk.html" target="_blank" title="閱讀vb.net中的RSS訂閱源,rss訂閱源是php"> 閱讀vb.net中的RSS訂閱源,rss訂閱源是php </a> </li> <li> 12. <a href="http://hk.uwenku.com/question/p-pwlsoebt-st.html" target="_blank" title="如何閱讀全文RSS訂閱"> 如何閱讀全文RSS訂閱 </a> </li> <li> 13. <a href="http://hk.uwenku.com/question/p-aznzzuse-bcs.html" target="_blank" title="如何爲多個訂閱源製作單個訂閱郵箱"> 如何爲多個訂閱源製作單個訂閱郵箱 </a> </li> <li> 14. <a href="http://hk.uwenku.com/question/p-bgncmwia-hu.html" target="_blank" title="如何讓RSS訂閱者再次閱讀舊的RSS項目?"> 如何讓RSS訂閱者再次閱讀舊的RSS項目? </a> </li> <li> 15. <a href="http://hk.uwenku.com/question/p-smpjmqkt-qq.html" target="_blank" title="如何製作RSS訂閱者計數器?"> 如何製作RSS訂閱者計數器? </a> </li> <li> 16. <a href="http://hk.uwenku.com/question/p-cfujjois-vu.html" target="_blank" title="WordPress的RSS訂閱源:定製特定類別的訂閱源"> WordPress的RSS訂閱源:定製特定類別的訂閱源 </a> </li> <li> 17. <a href="http://hk.uwenku.com/question/p-oyvbnzuo-no.html" target="_blank" title="我想創建一個可定製的RSS訂閱源"> 我想創建一個可定製的RSS訂閱源 </a> </li> <li> 18. <a href="http://hk.uwenku.com/question/p-ekznmoxs-qz.html" target="_blank" title="RSS訂閱WordPress(.COM)"> RSS訂閱WordPress(.COM) </a> </li> <li> 19. <a href="http://hk.uwenku.com/question/p-nrwnghal-bkg.html" target="_blank" title="Oracle 11g RSS訂閱"> Oracle 11g RSS訂閱 </a> </li> <li> 20. <a href="http://hk.uwenku.com/question/p-sugrlnry-bz.html" target="_blank" title="過濾RSS訂閱"> 過濾RSS訂閱 </a> </li> <li> 21. <a href="http://hk.uwenku.com/question/p-mppqigfk-pq.html" target="_blank" title="Actionscript 3.0 RSS訂閱"> Actionscript 3.0 RSS訂閱 </a> </li> <li> 22. <a href="http://hk.uwenku.com/question/p-hafagsuv-vd.html" target="_blank" title="管理RSS訂閱"> 管理RSS訂閱 </a> </li> <li> 23. <a href="http://hk.uwenku.com/question/p-biyjfzrl-bad.html" target="_blank" title="用PHP RSS訂閱"> 用PHP RSS訂閱 </a> </li> <li> 24. <a href="http://hk.uwenku.com/question/p-ybydodmh-bea.html" target="_blank" title="RSS訂閱解析"> RSS訂閱解析 </a> </li> <li> 25. <a href="http://hk.uwenku.com/question/p-acqmequo-tp.html" target="_blank" title="如何給我的Search.php文件添加一個RSS訂閱源?"> 如何給我的Search.php文件添加一個RSS訂閱源? </a> </li> <li> 26. <a href="http://hk.uwenku.com/question/p-tjdavyba-bbp.html" target="_blank" title="如何確定RSS訂閱訂閱者數量"> 如何確定RSS訂閱訂閱者數量 </a> </li> <li> 27. <a href="http://hk.uwenku.com/question/p-mlgubyab-bcu.html" target="_blank" title="RSS訂閱RSS源中的HTML代碼"> RSS訂閱RSS源中的HTML代碼 </a> </li> <li> 28. <a href="http://hk.uwenku.com/question/p-fbzksbni-zd.html" target="_blank" title="使用RRDTool來繪製RSS訂閱"> 使用RRDTool來繪製RSS訂閱 </a> </li> <li> 29. <a href="http://hk.uwenku.com/question/p-gzjalkbs-pm.html" target="_blank" title="從Facebook獲取用戶訂閱作爲RSS訂閱"> 從Facebook獲取用戶訂閱作爲RSS訂閱 </a> </li> <li> 30. <a href="http://hk.uwenku.com/question/p-pxximnul-vu.html" target="_blank" title="Google Play Store的RSS訂閱"> Google Play Store的RSS訂閱 </a> </li> </ul> </div> <div> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-6208739752673518" data-ad-slot="1575177025"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="padding-top-10"></div> </div> </div> <script type="text/javascript" src="http://img.uwenku.com/uwenku/script/side.js?t=1644592048261"></script> <script type="text/javascript" src="http://img.uwenku.com/uwenku/plugin/highlight/highlight.pack.js"></script> <link href="http://img.uwenku.com/uwenku/plugin/highlight/styles/docco.css" media="screen" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $('pre').each(function(i, e) { hljs.highlightBlock(e, "<span class='indent'> </span>", false) }); </script> <div class="col-lg-3 col-md-4 col-sm-5"> <div id="rightTop"> <div class="row"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6208739752673518" data-ad-slot="5415218910" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <div class="row sidebar panel panel-default"> <div class="panel-heading font-bold"> 最新問題 </div> <div class="m-b-sm m-t-sm clearfix"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-yjetlghp-mv.html" target="_blank" title="螺栓中的類型錯誤CMS"> 螺栓中的類型錯誤CMS </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-kqqxplja-ma.html" target="_blank" title="如何讀取R中的多個csv文件,並使用fread函數跳過最後一行"> 如何讀取R中的多個csv文件,並使用fread函數跳過最後一行 </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-bqpdgxhm-hn.html" target="_blank" title="從Flink 1.3.2升級到1.4.0 hadoop文件系統和路徑問題"> 從Flink 1.3.2升級到1.4.0 hadoop文件系統和路徑問題 </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-rsquypsa-ke.html" target="_blank" title="D3.js - 嵌套數據的作品,但選擇不遵循"> D3.js - 嵌套數據的作品,但選擇不遵循 </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-oljbtgar-dt.html" target="_blank" title="卡桑德拉CodecNotFoundException:編解碼器找不到請求的操作"> 卡桑德拉CodecNotFoundException:編解碼器找不到請求的操作 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-hzfpqyed-eo.html" target="_blank" title="爲什麼我不能打印()?"> 爲什麼我不能打印()? </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-kgtdfutl-gg.html" target="_blank" title="圖中不顯示閃亮"> 圖中不顯示閃亮 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-eahichhw-q.html" target="_blank" title="Django的css文件不起作用"> Django的css文件不起作用 </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-wtxobtnw-bk.html" target="_blank" title="無法從孩子"> 無法從孩子 </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-cecgwetc-bu.html" target="_blank" title="在頁面加載時觸發Javascript文本和圖片預覽"> 在頁面加載時觸發Javascript文本和圖片預覽 </a> </li> </ul> </div> </div> </div> <p class="article-nav-bar"></p> <div class="row sidebar article-nav"> <div class="row box_white visible-sm visible-md visible-lg margin-zero"> <div class="top"> <h3 class="title"><i class="glyphicon glyphicon-th-list"></i> 相關問題</h3> </div> <div class="article-relative-content"> <ul class="side_article_list"> <li class="side_article_list_item"> 1. <a href="http://hk.uwenku.com/question/p-tlqcnekh-bhr.html" target="_blank" title="製作一個RSS訂閱點擊"> 製作一個RSS訂閱點擊 </a> </li> <li class="side_article_list_item"> 2. <a href="http://hk.uwenku.com/question/p-eihbcspi-bav.html" target="_blank" title="點擊一個DIV訂閱RSS訂閱"> 點擊一個DIV訂閱RSS訂閱 </a> </li> <li class="side_article_list_item"> 3. <a href="http://hk.uwenku.com/question/p-gffxxohl-rd.html" target="_blank" title="建立一個RSS訂閱"> 建立一個RSS訂閱 </a> </li> <li class="side_article_list_item"> 4. <a href="http://hk.uwenku.com/question/p-dhdocchj-bhg.html" target="_blank" title="製作iTunes的Podcast RSS訂閱"> 製作iTunes的Podcast RSS訂閱 </a> </li> <li class="side_article_list_item"> 5. <a href="http://hk.uwenku.com/question/p-tzlddcjy-wk.html" target="_blank" title="如何在RSS訂閱"> 如何在RSS訂閱 </a> </li> <li class="side_article_list_item"> 6. <a href="http://hk.uwenku.com/question/p-wsoesbtm-ue.html" target="_blank" title="翻閱RSS訂閱"> 翻閱RSS訂閱 </a> </li> <li class="side_article_list_item"> 7. <a href="http://hk.uwenku.com/question/p-dyvyasqi-tn.html" target="_blank" title="主持一個動態的RSS訂閱"> 主持一個動態的RSS訂閱 </a> </li> <li class="side_article_list_item"> 8. <a href="http://hk.uwenku.com/question/p-mhifflve-bey.html" target="_blank" title="RSS訂閱LINQ"> RSS訂閱LINQ </a> </li> <li class="side_article_list_item"> 9. <a href="http://hk.uwenku.com/question/p-hmhwcwzz-bea.html" target="_blank" title="訂閱RSS源"> 訂閱RSS源 </a> </li> <li class="side_article_list_item"> 10. <a href="http://hk.uwenku.com/question/p-nycfgsjs-bns.html" target="_blank" title="ASP.Net RSS訂閱"> ASP.Net RSS訂閱 </a> </li> </ul> </div> </div> </div> </div> </div> </div> </div><!-- wrap end--> <!-- footer --> <footer id="footer"> <div class="bg-simple lt"> <div class="container"> <div class="row padder-v m-t"> <div class="col-xs-8"> <ul class="list-inline"> <li><a href="http://hk.uwenku.com/contact">聯系我們</a></li> <li>© 2020 HK.UWENKU.COM</li> <li><a target="_blank" href="https://beian.miit.gov.cn/">沪ICP备13005482号-4</a></li> <li><script type="text/javascript" src="https://v1.cnzz.com/z_stat.php?id=1280101193&web_id=1280101193"></script></li> <li><a href="http://www.uwenku.com/" target="_blank" title="优文库">简体中文</a></li> <li><a href="http://hk.uwenku.com/" target="_blank" title="優文庫">繁體中文</a></li> <li><a href="http://ru.uwenku.com/" target="_blank" title="поле вопросов и ответов">Русский</a></li> <li><a href="http://de.uwenku.com/" target="_blank" title="Frage - und - antwort - Park">Deutsch</a></li> <li><a href="http://es.uwenku.com/" target="_blank" title="Preguntas y respuestas">Español</a></li> <li><a href="http://hi.uwenku.com/" target="_blank" title="कार्यक्रम प्रश्न और उत्तर पार्क">हिन्दी</a></li> <li><a href="http://it.uwenku.com/" target="_blank" title="IL Programma di chiedere Park">Italiano</a></li> <li><a href="http://ja.uwenku.com/" target="_blank" title="プログラム問答園区">日本語</a></li> <li><a href="http://ko.uwenku.com/" target="_blank" title="프로그램 문답 단지">한국어</a></li> <li><a href="http://pl.uwenku.com/" target="_blank" title="program o park">Polski</a></li> <li><a href="http://tr.uwenku.com/" target="_blank" title="Program soru ve cevap parkı">Türkçe</a></li> <li><a href="http://vi.uwenku.com/" target="_blank" title="Đáp ứng viên">Tiếng Việt</a></li> <li><a href="http://fr.uwenku.com/" target="_blank" title="Programme interrogation Park">Française</a></li> </ul> </div> </div> </div> </div> </div> </footer> <!-- / footer --> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?f78a970f17b19a79fc477a3378096f29"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>