The first step is to create an instance of XMLOutputFactory:
XMLOutputFactory xof = XMLOutputFactory.newInstance();