Java method behind 'Copy XML to Clipboard'

If it’s public, what is the java class/method behind the ‘Copy XML to Clipboard’ option in the Shift + Right Click context menu on a vision window in the the Project Browser?

When our Ignition environment was first created (and for a few years after that), the tag structure was not well planned. Tags were pulled in from processors and never used. Multiple tags were created in different folders for a single OPC path on the same device; etc. In trying to go back and fix some of this, I’ve had good success manually copying XML to a text file and using python to find tag paths that are used in the window. I’d love to be able to automate the Copy XML step if I can.


What I’d really like to find is the class/method that returns the XML String so I can write to a file. I’m less interested in the String → Clipboard step.

I posted this in the afternoon/evening (across the US). Bump to see if there’s any interest in the morning.

Start by obtaining a DesignerContext. (:

From that, obtain a fully-configured serializer with .createSerializer().

Then add the window object to the serializer, and use .serializeXML() to yield your desired string. Or use one of the peer methods to serialize directly to a file or other stream.

You’ll note that there is also a .createDeserializer() method. Please report back when you reach the bottom of this rabbit hole… (:

Working with contexts is totally unsupported, of course.

1 Like

Note that this is based on an open window. I’m sure there’s a way to extract the serialized form from the window resource. No idea on that.

Naturally. It almost goes without saying.

Based on the number of (: in your reply I suspect the rabbit hole is probably pretty deep, but I’ll report as far as I get.

Noted. Thanks for pointing me in the right direction.

windowList = system.gui.getWindowNames()
for i in windowList:
	serializer = context.createSerializer()
	outputStream = FileOutputStream(outputDirectory+i+'.txt')
	serializer.serializeXML(outputStream, 'utf-8')

I imagine there is probably a more elegant way to do this, but this script accomplishes my goal. I haven’t looked into createDeserializer() (yet). Alas, there’s only so long I can spend scripting my work before I have to do the work…

Thanks again @pturmel for the help and thanks to @nmudge in another thread for the code to get a gateway context.