// output it using binary xml outputter
XMLStreamWriter streamWriter = new StAXDocumentSerializer(new FileOutputStream(tempFile));
streamWriter.writeStartDocument();
element.serializeAndConsume(streamWriter);
streamWriter.writeEndDocument();
// now let's read the binary file in to Axiom
XMLStreamReader streamReader = new StAXDocumentParser(new FileInputStream(tempFile));
StAXBuilder builder = new StAXOMBuilder(streamReader);
builder.getDocumentElement().serialize(new FileWriter(outputFile));