Complete mess atm, working through libxml2 issue with callback functions falling out of scope :\ , code moved from ELT however