Writing to db, converting xml