views:

13

answers:

0

Hi,

i have a little problem.

I must parse an xml file. I use the module "element" : http://code.google.com/p/python-elements/

Sometimes in the XML, an element is orphan but sometimes not :

<product />
....
<product>7</product>

I created a class Products with product as children :

class Products(Elements):
  _tag = "products"
  _children = Elements._children.copy()
  _children['product'] = ('product',int)
  ....

  def __init__(self,product=0):
      self.product = product

So, it's working, but when the element product become orphan, I have an error.

Yes it's logical, but when product is orphan i want it to have a value of O or something else but not an error.

So anyone has an idea ?

Thanks