Do you mean XFDF? If so, all you need to do is to call this.exportAsXFDF(),
which doesn't have to be in a trusted function, unless you want to specify
the file path to it.
And if you want XML, you can use the exportXFAData, with bXDP set to false.
cPath: "/c/Users/(my username)/Desktop/myData.xml",
No dice. I will also need to save the file based on some parameters within the form itself - so it doesn't overwrite the "myData.xml" each time.
This method can only be used from a privileged context, as is described in
the API reference.