RepositoryService repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
//獲取BpmnModel物件
BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstanceId);
//建立轉換物件
BpmnXMLConverter converter = new BpmnXMLConverter();
//把bpmnModel物件轉換成字元
byte[] bytes = converter.convertToXML(bpmnModel);
String xmlContenxt = new String(bytes);
xmlContenxt即為流程的xml