Encrypt an instance into XML, using lua code

I want to make a luau script that basically has a variable of an object, and by executing the code (EX: Studio command bar.) it generates an xml string (which is stored in workspace after it generated) for that object, depending on hierarchy, descendants, etc., which can be copied in a text document, and the document can be renamed to file.rbxlx, So it can be useable as a place file.
But i am sadly not capable to really understand it, can anyone capable doing this help, please?