Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 7e03e96dde1cbbdbc7cc96424cd9e059 > files > 392

python-feedparser-doc-5.1.3-3.fc18.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Relative Link Resolution &mdash; feedparser 5.1.3 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="_static/feedparser.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '5.1.3',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="feedparser 5.1.3 documentation" href="index.html" />
    <link rel="up" title="Advanced Features" href="advanced.html" />
    <link rel="next" title="Feed Type and Version Detection" href="version-detection.html" />
    <link rel="prev" title="Namespace Handling" href="namespace-handling.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="version-detection.html" title="Feed Type and Version Detection"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="namespace-handling.html" title="Namespace Handling"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">feedparser 5.1.3 documentation</a> &raquo;</li>
          <li><a href="advanced.html" accesskey="U">Advanced Features</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="relative-link-resolution">
<span id="advanced-base"></span><h1>Relative Link Resolution<a class="headerlink" href="#relative-link-resolution" title="Permalink to this headline">¶</a></h1>
<p>Many feed elements and attributes are <abbr title="Uniform Resource Identifier">URI</abbr>s.
<strong class="program">Universal Feed Parser</strong> resolves relative <abbr title="Uniform Resource Identifier">URI</abbr>s
according to the <a class="reference external" href="http://www.w3.org/TR/xmlbase/">XML:Base</a> specification.  We&#8217;ll see how
that works in a minute, but first let&#8217;s talk about which values are treated as
<abbr title="Uniform Resource Identifier">URI</abbr>s.</p>
<div class="section" id="which-values-are-uris">
<h2>Which Values Are <abbr title="Uniform Resource Identifier">URI</abbr>s<a class="headerlink" href="#which-values-are-uris" title="Permalink to this headline">¶</a></h2>
<p>These feed elements are treated as <abbr title="Uniform Resource Identifier">URI</abbr>s,
and resolved if they are relative:</p>
<ul class="simple">
<li><a class="reference internal" href="reference-entry-author_detail.html#reference-entry-author-detail-href"><em>entries[i].author_detail.href</em></a></li>
<li><a class="reference internal" href="reference-entry-comments.html#reference-entry-comments"><em>entries[i].comments</em></a></li>
<li><a class="reference internal" href="reference-entry-contributors.html#reference-entry-contributors-href"><em>entries[i].contributors[j].href</em></a></li>
<li><a class="reference internal" href="reference-entry-enclosures.html#reference-entry-enclosures-href"><em>entries[i].enclosures[j].href</em></a></li>
<li><a class="reference internal" href="reference-entry-id.html#reference-entry-id"><em>entries[i].id</em></a></li>
<li><a class="reference internal" href="reference-entry-license.html#reference-entry-license"><em>entries[i].license</em></a></li>
<li><a class="reference internal" href="reference-entry-link.html#reference-entry-link"><em>entries[i].link</em></a></li>
<li><a class="reference internal" href="reference-entry-links.html#reference-entry-links-href"><em>entries[i].links[j].href</em></a></li>
<li><a class="reference internal" href="reference-entry-publisher_detail.html#reference-entry-publisher-detail-href"><em>entries[i].publisher_detail.href</em></a></li>
<li><a class="reference internal" href="reference-entry-source.html#reference-entry-source-author-detail-href"><em>entries[i].source.author_detail.href</em></a></li>
<li><a class="reference internal" href="reference-entry-source.html#reference-entry-source-contributors-href"><em>entries[i].source.contributors[j].href</em></a></li>
<li><a class="reference internal" href="reference-entry-source.html#reference-entry-source-links-href"><em>entries[i].source.links[j].href</em></a></li>
<li><a class="reference internal" href="reference-feed-author_detail.html#reference-feed-author-detail-href"><em>feed.author_detail.href</em></a></li>
<li><a class="reference internal" href="reference-feed-contributors.html#reference-feed-contributors-href"><em>feed.contributors[i].href</em></a></li>
<li><a class="reference internal" href="reference-feed-docs.html#reference-feed-docs"><em>feed.docs</em></a></li>
<li><a class="reference internal" href="reference-feed-generator_detail.html#reference-feed-generator-detail-href"><em>feed.generator_detail.href</em></a></li>
<li><a class="reference internal" href="reference-feed-id.html#reference-feed-id"><em>feed.id</em></a></li>
<li><a class="reference internal" href="reference-feed-image.html#reference-feed-image-href"><em>feed.image.href</em></a></li>
<li><a class="reference internal" href="reference-feed-image.html#reference-feed-image-link"><em>feed.image.link</em></a></li>
<li><a class="reference internal" href="reference-feed-license.html#reference-feed-license"><em>feed.license</em></a></li>
<li><a class="reference internal" href="reference-feed-link.html#reference-feed-link"><em>feed.link</em></a></li>
<li><a class="reference internal" href="reference-feed-links.html#reference-feed-links-href"><em>feed.links[i].href</em></a></li>
<li><a class="reference internal" href="reference-feed-publisher_detail.html#reference-feed-publisher-detail-href"><em>feed.publisher_detail.href</em></a></li>
<li><a class="reference internal" href="reference-feed-textinput.html#reference-feed-textinput-link"><em>feed.textinput.link</em></a></li>
</ul>
<p>In addition, several feed elements may contain <abbr title="HyperText Markup Language">HTML</abbr>
or <abbr title="Extensible HyperText Markup Language">XHTML</abbr> markup. Certain elements and
attributes in <abbr title="HyperText Markup Language">HTML</abbr> can be relative
<abbr title="Uniform Resource Identifier">URI</abbr>s, and <strong class="program">Universal Feed Parser</strong> will
resolve these <abbr title="Uniform Resource Identifier">URI</abbr>s according to the same rules
as the feed elements listed above.</p>
<p>These feed elements may contain <abbr title="HyperText Markup Language">HTML</abbr> or
<abbr title="Extensible HyperText Markup Language">XHTML</abbr> markup.  In Atom feeds,
whether these elements are treated as <abbr title="HyperText Markup Language">HTML</abbr>
depends on the value of the type attribute.  In <abbr title="Rich Site Summary">RSS</abbr>
feeds, these values are always treated as <abbr title="HyperText Markup Language">HTML</abbr>.</p>
<ul class="simple">
<li><a class="reference internal" href="reference-entry-content.html#reference-entry-content-value"><em>entries[i].content[j].value</em></a></li>
<li><a class="reference internal" href="reference-entry-summary.html#reference-entry-summary"><em>entries[i].summary</em></a> (<a class="reference internal" href="reference-entry-summary_detail.html#reference-entry-summary-detail-value"><em>entries[i].summary_detail.value</em></a>)</li>
<li><a class="reference internal" href="reference-entry-title.html#reference-entry-title"><em>entries[i].title</em></a> (<a class="reference internal" href="reference-entry-title_detail.html#reference-entry-title-detail-value"><em>entries[i].title_detail.value</em></a>)</li>
<li><a class="reference internal" href="reference-feed-info.html#reference-feed-info"><em>feed.info</em></a> (<a class="reference internal" href="reference-feed-info-detail.html#reference-feed-info-detail-value"><em>feed.info_detail.value</em></a>)</li>
<li><a class="reference internal" href="reference-feed-rights.html#reference-feed-rights"><em>feed.rights</em></a> (<a class="reference internal" href="reference-feed-rights_detail.html#reference-feed-rights-detail-value"><em>feed.rights_detail.value</em></a>)</li>
<li><a class="reference internal" href="reference-feed-subtitle.html#reference-feed-subtitle"><em>feed.subtitle</em></a> (<a class="reference internal" href="reference-feed-subtitle_detail.html#reference-feed-subtitle-detail-value"><em>feed.subtitle_detail.value</em></a>)</li>
<li><a class="reference internal" href="reference-feed-title.html#reference-feed-title"><em>feed.title</em></a> (<a class="reference internal" href="reference-feed-title_detail.html#reference-feed-title-detail-value"><em>feed.title_detail.value</em></a>)</li>
</ul>
<p>When any of these feed elements contains <abbr title="HyperText Markup Language">HTML</abbr>
or <abbr title="Extensible HyperText Markup Language">XHTML</abbr> markup, the
following <abbr title="HyperText Markup Language">HTML</abbr> elements are treated as
<abbr title="Uniform Resource Identifier">URI</abbr>s and are resolved if they are
relative:</p>
<ul class="simple">
<li>&lt;a href=&#8221;...&#8221;&gt;</li>
<li>&lt;applet codebase=&#8221;...&#8221;&gt;</li>
<li>&lt;area href=&#8221;...&#8221;&gt;</li>
<li>&lt;blockquote cite=&#8221;...&#8221;&gt;</li>
<li>&lt;body background=&#8221;...&#8221;&gt;</li>
<li>&lt;del cite=&#8221;...&#8221;&gt;</li>
<li>&lt;form action=&#8221;...&#8221;&gt;</li>
<li>&lt;frame longdesc=&#8221;...&#8221;&gt;</li>
<li>&lt;frame src=&#8221;...&#8221;&gt;</li>
<li>&lt;head profile=&#8221;...&#8221;&gt;</li>
<li>&lt;iframe longdesc=&#8221;...&#8221;&gt;</li>
<li>&lt;iframe src=&#8221;...&#8221;&gt;</li>
<li>&lt;img longdesc=&#8221;...&#8221;&gt;</li>
<li>&lt;img src=&#8221;...&#8221;&gt;</li>
<li>&lt;img usemap=&#8221;...&#8221;&gt;</li>
<li>&lt;input src=&#8221;...&#8221;&gt;</li>
<li>&lt;input usemap=&#8221;...&#8221;&gt;</li>
<li>&lt;ins cite=&#8221;...&#8221;&gt;</li>
<li>&lt;link href=&#8221;...&#8221;&gt;</li>
<li>&lt;object classid=&#8221;...&#8221;&gt;</li>
<li>&lt;object codebase=&#8221;...&#8221;&gt;</li>
<li>&lt;object data=&#8221;...&#8221;&gt;</li>
<li>&lt;object usemap=&#8221;...&#8221;&gt;</li>
<li>&lt;q cite=&#8221;...&#8221;&gt;</li>
<li>&lt;script src=&#8221;...&#8221;&gt;</li>
</ul>
</div>
<div class="section" id="how-relative-uris-are-resolved">
<h2>How Relative <abbr title="Uniform Resource Identifier">URI</abbr>s Are Resolved<a class="headerlink" href="#how-relative-uris-are-resolved" title="Permalink to this headline">¶</a></h2>
<p><strong class="program">Universal Feed Parser</strong> resolves relative <abbr title="Uniform Resource Identifier">URI</abbr>s
according to the <a class="reference external" href="http://www.w3.org/TR/xmlbase/">XML:Base</a> specification.
This defines a hierarchical inheritance system, where one element can define
the base <abbr title="Uniform Resource Identifier">URI</abbr> for itself and all of its
child elements, using an xml:base attribute.  A child element can then override
its parent&#8217;s base <abbr title="Uniform Resource Identifier">URI</abbr> by redeclaring
xml:base to a different value.</p>
<p>If no xml:base is specified, the feed has a default base <abbr title="Uniform Resource Identifier">URI</abbr>
defined in the Content-Location <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header.</p>
<p>If no Content-Location <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header is
present, the <abbr title="Uniform Resource Locator">URL</abbr> used to retrieve the feed
itself is the default base <abbr title="Uniform Resource Identifier">URI</abbr> for all
relative links within the feed.  If the feed was retrieved via an
<abbr title="Hypertext Transfer Protocol">HTTP</abbr> redirect (any <abbr title="Hypertext Transfer Protocol">HTTP</abbr>
3xx status code), then the final <abbr title="Uniform Resource Locator">URL</abbr> of the
feed is the default base <abbr title="Uniform Resource Identifier">URI</abbr>.</p>
<p>For example, an xml:base on the root-level element sets the base
<abbr title="Uniform Resource Identifier">URI</abbr> for all <abbr title="Uniform Resource Identifier">URI</abbr>s in the feed.</p>
<div class="section" id="xml-base-on-the-root-level-element">
<h3>xml:base on the root-level element<a class="headerlink" href="#xml-base-on-the-root-level-element" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">feedparser</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s">&quot;http://feedparser.org/docs/examples/base.xml&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">link</span>
<span class="go">u&#39;http://example.org/index.html&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">generator_detail</span><span class="o">.</span><span class="n">href</span>
<span class="go">u&#39;http://example.org/generator/&#39;</span>
</pre></div>
</div>
<p>An xml:base attribute on an &lt;entry&gt; overrides the xml:base on the parent &lt;feed&gt;.</p>
</div>
<div class="section" id="overriding-xml-base-on-an-entry">
<h3>Overriding xml:base on an &lt;entry&gt;<a class="headerlink" href="#overriding-xml-base-on-an-entry" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">feedparser</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s">&quot;http://feedparser.org/docs/examples/base.xml&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">link</span>
<span class="go">u&#39;http://example.org/archives/000001.html&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">author_detail</span><span class="o">.</span><span class="n">href</span>
<span class="go">u&#39;http://example.org/about/&#39;</span>
</pre></div>
</div>
<p>An xml:base on &lt;content&gt; overrides the xml:base on the parent &lt;entry&gt;.  In
addition, whatever the base <abbr title="Uniform Resource Identifier">URI</abbr> is for
the &lt;content&gt; element (whether defined directly on the &lt;content&gt; element, or
inherited from the parent element) is used as the base <abbr title="Uniform Resource Identifier">URI</abbr>
for the embedded <abbr title="HyperText Markup Language">HTML</abbr>
or <abbr title="Extensible HyperText Markup Language">XHTML</abbr> markup within the
content.</p>
</div>
<div class="section" id="relative-links-within-embedded-html">
<h3>Relative links within embedded <abbr title="HyperText Markup Language">HTML</abbr><a class="headerlink" href="#relative-links-within-embedded-html" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">feedparser</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s">&quot;http://feedparser.org/docs/examples/base.xml&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">content</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">value</span>
<span class="go">u&#39;&lt;p id=&quot;anchor1&quot;&gt;&lt;a href=&quot;http://example.org/archives/000001.html#anchor2&quot;&gt;skip to anchor 2&lt;/a&gt;&lt;/p&gt;</span>
<span class="go">&lt;p&gt;Some content&lt;/p&gt;</span>
<span class="go">&lt;p id=&quot;anchor2&quot;&gt;This is anchor 2&lt;/p&gt;&#39;</span>
</pre></div>
</div>
<p>The xml:base affects other attributes in the element in which it is declared.</p>
</div>
<div class="section" id="xml-base-and-sibling-attributes">
<h3>xml:base and sibling attributes<a class="headerlink" href="#xml-base-and-sibling-attributes" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">feedparser</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s">&quot;http://feedparser.org/docs/examples/base.xml&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">links</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">rel</span>
<span class="go">u&#39;service.edit&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">links</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">href</span>
<span class="go">u&#39;http://example.com/api/client/37&#39;</span>
</pre></div>
</div>
<p>If no xml:base is specified on the root-level element, the default base
<abbr title="Uniform Resource Identifier">URI</abbr> is given in the Content-Location
<abbr title="Hypertext Transfer Protocol">HTTP</abbr> header.  This can still be
overridden by any child element that declares an xml:base attribute.</p>
</div>
<div class="section" id="content-location-http-header">
<h3>Content-Location <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header<a class="headerlink" href="#content-location-http-header" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">feedparser</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s">&quot;http://feedparser.org/docs/examples/http_base.xml&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">link</span>
<span class="go">u&#39;http://example.org/index.html&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">link</span>
<span class="go">u&#39;http://example.org/archives/000001.html&#39;</span>
</pre></div>
</div>
<p>Finally, if no root-level xml:base is declared, and no Content-Location
<abbr title="Hypertext Transfer Protocol">HTTP</abbr> header is present, the
<abbr title="Uniform Resource Locator">URL</abbr> of the feed itself is the default base
<abbr title="Uniform Resource Identifier">URI</abbr>.  Again, this can still be overridden
by any element that declares an xml:base attribute.</p>
</div>
<div class="section" id="feed-url-as-default-base-uri">
<h3>Feed <abbr title="Uniform Resource Locator">URL</abbr> as default base <abbr title="Uniform Resource Identifier">URI</abbr><a class="headerlink" href="#feed-url-as-default-base-uri" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">feedparser</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s">&quot;http://feedparser.org/docs/examples/no_base.xml&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">feed</span><span class="o">.</span><span class="n">link</span>
<span class="go">u&#39;http://feedparser.org/docs/examples/index.html</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">link</span>
<span class="go">u&#39;http://example.org/archives/000001.html&#39;</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="disabling-relative-uris-resolution">
<span id="advanced-base-disable"></span><h2>Disabling Relative <abbr title="Uniform Resource Identifier">URI</abbr>s Resolution<a class="headerlink" href="#disabling-relative-uris-resolution" title="Permalink to this headline">¶</a></h2>
<p>Though not recommended, it is possible to disable <strong class="program">Universal Feed Parser</strong>&#8216;s relative
<abbr title="Uniform Resource Identifier">URI</abbr> resolution by setting feedparser.RESOLVE_RELATIVE_URIS to <tt class="docutils literal"><span class="pre">0</span></tt>.</p>
<div class="section" id="how-to-disable-relative-uri-resolution">
<h3>How to disable relative <abbr title="Uniform Resource Identifier">URI</abbr> resolution<a class="headerlink" href="#how-to-disable-relative-uri-resolution" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">feedparser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">feedparser</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s">&#39;http://feedparser.org/docs/examples/base.xml&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">content</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">base</span>
<span class="go">u&#39;http://example.org/archives/000001.html&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">d</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">content</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">value</span>
<span class="go">&lt;p id=&quot;anchor1&quot;&gt;&lt;a href=&quot;http://example.org/archives/000001.html#anchor2&quot;&gt;skip to anchor 2&lt;/a&gt;&lt;/p&gt;</span>
<span class="go">&lt;p&gt;Some content&lt;/p&gt;</span>
<span class="go">&lt;p id=&quot;anchor2&quot;&gt;This is anchor 2&lt;/p&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">feedparser</span><span class="o">.</span><span class="n">RESOLVE_RELATIVE_URIS</span> <span class="o">=</span> <span class="mi">0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d2</span> <span class="o">=</span> <span class="n">feedparser</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s">&#39;http://feedparser.org/docs/examples/base.xml&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d2</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">content</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">base</span>
<span class="go">u&#39;http://example.org/archives/000001.html&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">d2</span><span class="o">.</span><span class="n">entries</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">content</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">value</span>
<span class="go">&lt;p id=&quot;anchor1&quot;&gt;&lt;a href=&quot;#anchor2&quot;&gt;skip to anchor 2&lt;/a&gt;&lt;/p&gt;</span>
<span class="go">&lt;p&gt;Some content&lt;/p&gt;</span>
<span class="go">&lt;p id=&quot;anchor2&quot;&gt;This is anchor 2&lt;/p&gt;</span>
</pre></div>
</div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Relative Link Resolution</a><ul>
<li><a class="reference internal" href="#which-values-are-uris">Which Values Are <abbr title="Uniform Resource Identifier">URI</abbr>s</a></li>
<li><a class="reference internal" href="#how-relative-uris-are-resolved">How Relative <abbr title="Uniform Resource Identifier">URI</abbr>s Are Resolved</a><ul>
<li><a class="reference internal" href="#xml-base-on-the-root-level-element">xml:base on the root-level element</a></li>
<li><a class="reference internal" href="#overriding-xml-base-on-an-entry">Overriding xml:base on an &lt;entry&gt;</a></li>
<li><a class="reference internal" href="#relative-links-within-embedded-html">Relative links within embedded <abbr title="HyperText Markup Language">HTML</abbr></a></li>
<li><a class="reference internal" href="#xml-base-and-sibling-attributes">xml:base and sibling attributes</a></li>
<li><a class="reference internal" href="#content-location-http-header">Content-Location <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header</a></li>
<li><a class="reference internal" href="#feed-url-as-default-base-uri">Feed <abbr title="Uniform Resource Locator">URL</abbr> as default base <abbr title="Uniform Resource Identifier">URI</abbr></a></li>
</ul>
</li>
<li><a class="reference internal" href="#disabling-relative-uris-resolution">Disabling Relative <abbr title="Uniform Resource Identifier">URI</abbr>s Resolution</a><ul>
<li><a class="reference internal" href="#how-to-disable-relative-uri-resolution">How to disable relative <abbr title="Uniform Resource Identifier">URI</abbr> resolution</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="namespace-handling.html"
                        title="previous chapter">Namespace Handling</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="version-detection.html"
                        title="next chapter">Feed Type and Version Detection</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/resolving-relative-links.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="version-detection.html" title="Feed Type and Version Detection"
             >next</a> |</li>
        <li class="right" >
          <a href="namespace-handling.html" title="Namespace Handling"
             >previous</a> |</li>
        <li><a href="index.html">feedparser 5.1.3 documentation</a> &raquo;</li>
          <li><a href="advanced.html" >Advanced Features</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2004-2008 Mark Pilgrim, 2010-2012 Kurt McKee.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>