Read XML content along with unsaved changes

XML content upon a event trigerred under menu:action using saveXML function but it returns only the saved contents, but in my usecase I want to pass unsaved contents of XML as well to the backend service, how to achieve it?

function LayoutAction(eventBus, editorActions, bpmnjs) {
eventBus.on(“menu:action”, function (action) {
if (action === “performBPMNLayout”) {
console.log(“helloooo”);
editorActions.trigger(“performBPMNLayout”);
}
});

editorActions.register({
performBPMNLayout: function () {
// Replace with your backend service call logic
console.log(“Triggering backend service…”);
bpmnjs.saveXML(function (err, xml) {
console.log(err)
if (!err) {
console.log(xml);
}
});
},
});
}

LayoutAction.$inject = [“eventBus”, “editorActions”, “bpmnjs”];

module.exports = LayoutAction;