擅长:python、mysql、java
<p>我将使用<a href="https://github.com/martinblech/xmltodict">^{<cd1>}</a>从<code>XML</code>数据结构中创建一个python字典,并将此字典传递给上下文中的模板:</p>
<pre><code>import urllib2
import xmltodict
def homepage(request):
file = urllib2.urlopen('https://www.goodreads.com/review/list/20990068.xml?key=nGvCqaQ6tn9w4HNpW8kquw&v=2&shelf=toread')
data = file.read()
file.close()
data = xmltodict.parse(data)
return render_to_response('my_template.html', {'data': data})
</code></pre>