Save XML on button click BPMN.io in React js

I have created BPMN diagram based on bussiness needs. Also am having save button to save the XML of created diagram. On clicking save button I want to get XML of created diagram.
Attached Screenshot for your refference.

Thanks in advance

save_xml

saveXML is the opposite of importXML. Call it to export the diagram as XML.

can you brief it please.

I have tried below code but not working.

diagram.exportXML(bpmnjs)

There is no exportXML, as I said, you can use saveXML:

bpmnJS.saveXML().then({ xml } => console.log(xml));

Thanks Philippfromme.

Now working, Please provide me clarification for the points given below.

  1. How to integrate in react js web application.
  2. For deployment, Whether separate server is needed to run BPMN.io or can i run in my node js server
  1. Here’s an example: https://github.com/bpmn-io/react-bpmn
  2. Not sure what you mean. bpmn-js is a front-end library.

Do you have Angular example for saving the diagram to XML file?