Exemplo n.º 1
0
    def submitXML (self, longfile):
        out = ""
        while True:
            data = longfile.file.read(8192)
            if data == "":
                break
            out += data
        import xmltodict

        a = xmltodict.xml2json(out)
        data = json.loads(a)

        cnxn = MySQLdb.connect ("localhost", "root", "", "wateraid")
        cursor = cnxn.cursor()

        ind = self.AddObject (cursor, data)

        print ind

        cnxn.commit()
        cnxn.close()

        cherrypy.response.headers['Content-type'] = "application/json"
        return json.dumps (data, indent=3)
Exemplo n.º 2
0
import xmltodict, json

fil = open("wateraidiatiorganisationdata201012.xml")
txt = fil.read()

a = xmltodict.xml2json(txt)


data = json.loads(a)['iati-organisations']['iati-organisation']