Reorganizing XML and Insert into database