tags:

views:

34

answers:

1

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?

+1  A: 

Perhaps use

for game in tree.games[0].game[0:4]:
    print(lxml.objectify.dump(game))

which yields

game = None [ObjectifiedElement]
  * slot = '1'
    id = 'Bric A Bloc' [StringElement]
    title-text = 'BricABloc Hoorah' [StringElement]
    link = 'Fruit Splat' [StringElement]

print(game) shows that each game is an lxml.ojectify.ObjectifiedElement.

unutbu