Accessing Component XML

Hello,
On Ignition 7.9.
I am writing a shared script to read a csv of window names from a file, open up the windows, and copy the xml of the components to their own text files. Right now, I am successfully getting into the root container of each window and listing the components using getComponents().
Is there any way I can access the xml for each component this way?
Alternatively, can I copy/paste selected components via scripting?
Thank you