rahman.bd
rahman.bd

Reputation: 525

Parsing <geo:lat>, <geo:long> tags value using feedparser in python!

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!

Upvotes: 1

Views: 870

Answers (2)

J. Ceron
J. Ceron

Reputation: 1345

<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']

Upvotes: 0

systempuntoout
systempuntoout

Reputation: 74084

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']

Upvotes: 2

Related Questions