Zend_Feed-ConsumingAtomSingle.xml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.feed.consuming-atom-single-entry">
  4. <title>Consuming a Single Atom Entry</title>
  5. <para>
  6. Single Atom <code>&lt;entry&gt;</code> elements are also valid by themselves. Usually the
  7. <acronym>URL</acronym> for an entry is the feed's <acronym>URL</acronym> followed by
  8. <code>/&lt;entryId&gt;</code>, such as <code>http://atom.example.com/feed/1</code>, using
  9. the example <acronym>URL</acronym> we used above.
  10. </para>
  11. <para>
  12. If you read a single entry, you will still have a <classname>Zend_Feed_Atom</classname>
  13. object, but it will automatically create an "anonymous" feed to contain the entry.
  14. </para>
  15. <example id="zend.feed.consuming-atom-single-entry.example.atom">
  16. <title>Reading a Single-Entry Atom Feed</title>
  17. <programlisting language="php"><![CDATA[
  18. $feed = new Zend_Feed_Atom('http://atom.example.com/feed/1');
  19. echo 'The feed has: ' . $feed->count() . ' entry.';
  20. $entry = $feed->current();
  21. ]]></programlisting>
  22. </example>
  23. <para>
  24. Alternatively, you could instantiate the entry object directly if you know you are accessing
  25. an <code>&lt;entry&gt;</code>-only document:
  26. </para>
  27. <example id="zend.feed.consuming-atom-single-entry.example.entryatom">
  28. <title>Using the Entry Object Directly for a Single-Entry Atom Feed</title>
  29. <programlisting language="php"><![CDATA[
  30. $entry = new Zend_Feed_Entry_Atom('http://atom.example.com/feed/1');
  31. echo $entry->title();
  32. ]]></programlisting>
  33. </example>
  34. </sect1>
  35. <!--
  36. vim:se ts=4 sw=4 et:
  37. -->