Tuesday 12 August 2008

Dom4j : DocumentHelper.createDocument()

Got this error from a xml file created using the Dom4j API.


javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The markup in the document preceding the root element must be well-formed.


We were missing the xml header in the file



because we didn't call the DocumentHelper.createDocument() method!


import org.dom4j.Document;
import org.dom4j.DocumentHelper;

Document document = DocumentHelper.createDocument();