I am using feedparser for parsing from XML file.But I couldn't parse <开发者_如何学编程geo:lat>
, <geo:long>
tags using feedparser from that file! Do you people have any idea how I can parse those tags using feedparser in python?
Thanks in advance!
Feedparser should parse Basic Geo namespace with extension name geo without problem.
Check that your XML has http://www.w3.org/2003/01/geo/wgs84_pos# namespace declaration like:
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
This snippet should work:
import feedparser
d = feedparser.parse('http://yourfeed.xml')
print d.entries[0].['geo_lat']
print d.entries[0].['geo_long']
<rss version="2.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:dc="http://purl.org/dc/elements/1.1/">
working example:
import feedparser
for item in d['items']`
print item['geo_lat']
print item['geo_long']
精彩评论