fix - check validity of xml (rather than assume char(0) = '<')