Require xmlbuilder if it is undefined

Previously this would only be required if window was undefined but checking instead for xmlbuilder being undefined allows this to be used in contexts that have a window but do not provide xmlbuilder.