You are not logged in.

#1 2014-01-08 01:41:21

3xOSC
Member
Registered: 2013-03-18
Posts: 107

[SOLVED][Python] XML parsing can't get entries

Hi,

I have been following some python examples on how to parse XML.  I started out on an example XML (pulled from a tutorial website)

http://ix.io/9JU

By putting the "example.xml" into this script:

http://ix.io/9JY which successfully returns the values:  1, 4 and 68

However, putting it through a similar, yet a biiiit more complex example, which is the XML returned from a mail atom feed:
http://ix.io/9JT  no results get returned.


Of course, I have changed the file name from example.xml to mail.xml, and instead of using country, which I am not interested in, I am 'entry', hoping that, for each entry, I am able to extract the title and author.  (http://ix.io/9JZ)
With this slight alteration, I do not get a single output.  The program just termites silently.

Any pointers would be appreciated.

Last edited by 3xOSC (2014-01-09 06:55:40)

Offline

#2 2014-01-08 21:30:49

Yannick_LM
Member
Registered: 2008-12-22
Posts: 142

Re: [SOLVED][Python] XML parsing can't get entries

You probably are having problems because you are not handling the namespaces correctly:
See lxml tutorial for more info.

(lxml shares a common API with elementree, but the doc is much nicer, IMHO)

By the way, if your end goal is to parse atom feeds, I suggest you have a look at feedparser

Hope this helps

Offline

#3 2014-01-09 06:55:25

3xOSC
Member
Registered: 2013-03-18
Posts: 107

Re: [SOLVED][Python] XML parsing can't get entries

My end goal is to parse atom feeds.  I took a look at the feedparser and it came with EVERYTHING i needed and more.

It did help.  Thank you SO much Yannick.

Last edited by 3xOSC (2014-01-09 06:55:57)

Offline

Board footer

Powered by FluxBB