How to print an Objectified Element?

Posted by BeeBand on Stack Overflow See other posts from Stack Overflow or by BeeBand
Published on 2010-06-06T15:04:50Z Indexed on 2010/06/06 16:02 UTC
Read the original article Hit count: 246

Filed under:
|

I have xml of the format:

<channel>
    <games>
        <game slot='1'>
            <id>Bric A Bloc</id>
            <title-text>BricABloc Hoorah</title-text>
            <link>Fruit Splat</link>
        </game>
    </games>
</channel>

I've parsed this xml using lxml.objectify, via:

tree = objectify.parse(file)

There will potentially be a number of <game>s underneath <games>. I understand that I can generate a list of <game> objects via:

[ tree.games[0].game[0:4] ]

My question is, what class are those objects and is there a function to print any object of whatever class these objects belong to?

© Stack Overflow or respective owner

Related posts about python

Related posts about lxml