Libxmljs mem leak workaround

Fix for #2.  Essentially orders xml manipulations so that node removal actions are done first.  I did not get seg fault when I ran 250 times so I am assuming it is fixed.