def importxml(db, xmlinput):
 import cStringIO
 import xml.dom.minidom
 try:
  doc = xml.dom.minidom.parseString(xmlinput)
 except:
  raise Exception('XML parse error')
 parent = doc.childNodes[0].tagName
 csvout = csvheader(parent, doc.childNodes[0].childNodes)
 for subnode in doc.childNodes:
  csvout = (csvout + csvdata(subnode.childNodes))
 fh = cStringIO.StringIO()
 fh.write(csvout)
 fh.seek(0, 0)
 db[parent].import_from_csv_file(fh)

def importxml ( db , xmlinput ) : import cStringIO import xml . dom . minidom try : doc = xml . dom . minidom . parseString ( xmlinput ) except : raise Exception ( 'XML parse error' ) parent = doc . childNodes [ 0 ] . tagName csvout = csvheader ( parent , doc . childNodes [ 0 ] . childNodes ) for subnode in doc . childNodes : csvout = ( csvout + csvdata ( subnode . childNodes ) ) fh = cStringIO . StringIO ( ) fh . write ( csvout ) fh . seek ( 0 , 0 ) db [ parent ] . import_from_csv_file ( fh )
converts the xml to a csv compatible with the import_from_csv_file of web2py @todo: rewrite this to go via s3resource for proper auth checking .