Refactored to use libxmljs