How to edit bpmn xml targetNamespace?

Such bpmn xml file,if i want to edit its targetNamespace with bpmn methods or other js methods,what should i do?
Thank you.

Here’s an example of editing the target namespace on the definitions object:

I saw its just edit in definitions,so how can i let it to edit and change the result for xml?5747662815581

Have you tried bpmnJS.saveXML((err, xml) => console.log(xml))?

I just tried like this,this is what I want to be,thank you very much guys!

        const _this = this
        const bpmnjs = _this.bpmnModeler
        var definitions = bpmnjs.getDefinitions();
        definitions.set("targetNamespace", _this.params.category);
        _this.bpmnModeler.saveXML({ format: true }, function(err, xml) {

So is there still no other way to change target namespace? I guess the methods starting with an underline do not belong to the “public” api. I mean, javascript allows us to use those methods anyway but this approach doesn’t seem to be right.

And as stated by @523034426, if we do it like here and export the XML, the target namespace remains untouched.

EDIT even using _setDefinitions has no effect on the exported XML.

EDIT 2 sorry, my bad. It works just fine with modeler.getDefinitions().set('targetNamespace', 'foo') or modeler.getDefinitions().targetNamespace = 'foo'.