File: atom-detail.rst

package info (click to toggle)
feedparser 5.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,980 kB
  • sloc: xml: 11,438; python: 4,238; makefile: 19
file content (49 lines) | stat: -rwxr-xr-x 1,649 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Getting Detailed Information on Atom Elements
=============================================

Several Atom elements share the Atom content model: title, subtitle, rights,
summary, and of course content. (Atom 0.3 also had an info element which
shared this content model.) :program:`Universal Feed Parser` captures all
relevant metadata about these elements, most importantly the content type and
the value itself.

Detailed Information on Feed Elements
-------------------------------------

::

    >>> import feedparser
    >>> d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
    >>> d.feed.title_detail
    {'type': u'text/plain',
    'base': u'http://example.org/',
    'language': u'en',
    'value': u'Sample Feed'}
    >>> d.feed.subtitle_detail
    {'type': u'text/html',
    'base': u'http://example.org/',
    'language': u'en',
    'value': u'For documentation <em>only</em>'}
    >>> d.feed.rights_detail
    {'type': u'text/html',
    'base': u'http://example.org/',
    'language': u'en',
    'value': u'<p>Copyright 2004, Mark Pilgrim</p>'}
    >>> d.entries[0].title_detail
    {'type': 'text/plain',
    'base': u'http://example.org/',
    'language': u'en',
    'value': u'First entry title'}
    >>> d.entries[0].summary_detail
    {'type': u'text/plain',
    'base': u'http://example.org/',
    'language': u'en',
    'value': u'Watch out for nasty tricks'}
    >>> len(d.entries[0].content)
    1
    >>> d.entries[0].content[0]
    {'type': u'application/xhtml+xml',
    'base': u'http://example.org/entry/3',
    'language': u'en-US'
    'value': u'<div>Watch out for <span> nasty tricks</span></div>'}