Reduced code duplication in libxml classes