#NEWLINE# def __from_xml( self , xmlnode ) : #NEWLINE# #INDENT# 'Initialize a `Form` object from an XML element.\n\n        :Parameters:\n            - `xmlnode`: the XML element.\n        :Types:\n            - `xmlnode`: `libxml2.xmlNode`\n        ' #NEWLINE# self . fields = [ ] #NEWLINE# self . reported_fields = [ ] #NEWLINE# self . items = [ ] #NEWLINE# self . title = None #NEWLINE# self . instructions = None #NEWLINE# if ( ( xmlnode . type != 'element' ) or ( xmlnode . name != 'x' ) or ( xmlnode . ns ( ) . content != DATAFORM_NS ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Not a form: ' + xmlnode . serialize ( ) ) ) #NEWLINE# #UNINDENT# self . type = xmlnode . prop ( 'type' ) #NEWLINE# if ( not ( self . type in self . allowed_types ) ) : #NEWLINE# #INDENT# raise BadRequestProtocolError ( ( 'Bad form type: %r' % ( self . type , ) ) ) #NEWLINE# #UNINDENT# child = xmlnode . children #NEWLINE# while child : #NEWLINE# #INDENT# if ( ( child . type != 'element' ) or ( child . ns ( ) . content != DATAFORM_NS ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( child . name == 'title' ) : #NEWLINE# #INDENT# self . title = from_utf8 ( child . getContent ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( child . name == 'instructions' ) : #NEWLINE# #INDENT# self . instructions = from_utf8 ( child . getContent ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( child . name == 'field' ) : #NEWLINE# #INDENT# self . fields . append ( Field . _new_from_xml ( child ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . name == 'item' ) : #NEWLINE# #INDENT# self . items . append ( Item . _new_from_xml ( child ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( child . name == 'reported' ) : #NEWLINE# #INDENT# self . __get_reported ( child ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# child = child . __next__