Custom TreeItem Parameters
The ITcSmTreeItem interface is supported by every TwinCAT tree item and has a very generic character. To support the specification of all the devices, boxes and terminals, together with many other different types of tree items, all custom parameters of a tree item are accessible via the XML representation of the tree item. This XML-String can be accessed by the method ITcSmTreeItem::ProduceXml and its counterpart ITcSmTreeItem::ConsumeXml. This function pair has the same functionality as the "Export XML Description ..." and "Import XML Description ..." commands from the main menu of the TwinCAT IDE (see snapshot below).

With this Import/Export functionset, many parts of a script or automation code can be tested and tailored conveniently, before it is developed within the coding language - simply by the process of exporting tree item data, changing its content and re-importing it.
Best practice is to export the XML content first, change its content, importing it within the IDE and then, if everything goes successfully, package it into the programming/script code for handling it via the methods ProduceXml and ConsumeXml.