You can use the Alloy API. Generating an instance and writing it as an XML file can be easily done following those steps:
Read the alloy model from its source file.
model = CompUtil.parseEverything_fromFile(null, null, "yourmodel.als");
Get the command to execute. for example :
Command cmd=model.getAllCommands().get(0);
Execute the model using the command obtained in step 2
A4Solution solution= TranslateAlloyToKodkod.execute_command(null, model.getAllReachableSigs(), cmd, new A4Options());
Write the solution generated in step 3
solution.writeXML("path/to/your.xml");
Examples can be found in the edu.mit.csail.sdg.alloy4whole package of the Alloy jar file