Hi everyone,
I couldn't find answers to this question on the forum, so I will post it as new one.
I am working on a script in ARIS and I have a structure in a string variable that I want to print in file.
I want to be .xml file that will contain the structure that is stored in the variable.
How can I do this?
Many thanks
Kay Fischbach on
Could you give an example string, (doesn't need to be filled with real data, just replace any real data with fake/test data).
How I would go about this:
Where
After creating the output object you can start adding elements to it.
Basic child Nodes would be added with
where
Note that the "addElement" method directly returns the newly created element-object, so you can assign the return value to a variable to use it later (like I did with "childElement").
You can put the "addElement" method-call into a loop to iterate through your ARIS objects and create as many elements as you have ARIS objects.
To set the xml-element attribute values that you got from splitting the ARIS-attribute-value with regex, you can use
childElement.setAttribute("testAttribute", "testAttributeValue");where
ARIS-script uses an implementation of JDOM, so if you want to know what else you can do with elements, take a look at http://www.jdom.org/docs/apidocs/ and in the lower left panel select "Element" to get a list of methods you can use with objects of the type "Element" in the right panel.
After you are done with everything, write the data to the file with
Note: if you created a new file for the xml-file, you'll have to add it to the files to transfer to the client, after writing the data to the file. Do so by using
Context.addOutputFileName("additionalXML.xml");where
If you don't use the "addOutputFileName" method, the file would never be transferred to the client and subsequently it would not open after the report is done with the execution. If you used "Context.getSelectedFile()" when creating the object you do NOT have to use the addOutputFileName method - the selected file is part of the files to transfer to the client by default.