}
// TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost. See Mozilla bugzilla 361722
Scriptable jsXML = (Scriptable) ScriptableObject.callMethod((Scriptable) o, "copy", new Object[0]);
Wrapper wrapper = (Wrapper) ScriptableObject.callMethod((XMLObject)jsXML, "getXmlObject", new Object[0]);
XmlObject xmlObject = (XmlObject)wrapper.unwrap();
try {
StAXOMBuilder builder = new StAXOMBuilder(xmlObject.newInputStream());
OMElement omElement = builder.getDocumentElement();