[GData Python client] Getting value from namespace item

64 views
Skip to first unread message

Tom

unread,
Oct 14, 2009, 10:52:32 AM10/14/09
to Google Data Protocol
Hi there,

While working with the gdata YouTube API, I've come across a problem
when trying to get a value from a namespace item not containing any
text.

When I want to retrieve the text from a item, it's pretty easy:

namespace item:
<?xml version='1.0' encoding='UTF-8'?>
<ns0:title type="text" xmlns:ns0="http://www.w3.org/2005/
Atom">Merry Christmas and a happy new year!!</ns0:title>

>>> for entry in feed.entry:
... print entry.title.text

or even the 'type' when requesting the entry.title.type


I'm wondering if it's possible to the info of the favoriteCount and
viewCount on a namespace like this:

<?xml version='1.0' encoding='UTF-8'?>
<ns0:statistics favoriteCount="40" viewCount="22544"
xmlns:ns0="http://gdata.youtube.com/schemas/2007" />

When trying to print, for example, a ' entry.statistics.viewCount', I
get the error that a 'Statistics' object had no attribute 'viewCount'.
Is there an easy way to retrieve this value?

I think it will be a bit bloated to start using regular expressions on
each statistic item to retrieve the information.

I hope someone can help me out.

Regards, Tom
Reply all
Reply to author
Forward
0 new messages