How to get the xml of a sprite using JS

how do you get the xml string for a sprite using a JS function?
i want to make a project where sprite xml is sent over MQTT to other projects which open it using
my sciSnap! script pic
I tried looking through the Snap! code on Github, but i couldn't find anything.

I have used a block that could load the entire project's XML but not a single sprite's xml.

i do have a project that splits a project xml into sprite xml, but I dont think it's fully reliable.

Scene importing V3

I think there must be a way to do it, because Snap! gets the sprite xml when you export the sprite

i fixed it by adding a wait block to the importing process

You actually can get the xml of a script, if it has been edited (which includes moving it or editing an input, e.g. enter an input and hit enter)...

untitled script pic

Unfortunately the user has to edit or drag and drop a script (and you can say the script, then drag and drop the script in the speech bubble back onto the speech bubble, and it'll work).


And to answer your actual question, I did a bit of searching the console, and found out that you can literally just do this

sprite.toXMLString()

And sprite is a SpriteMorph aka, what you get from the (object ) reporter.

nice! thanks :D