It is possible to create a custom XML file as well. You would do this if you want to do a lot of formatting on the XML you are trying to create and/or have a custom document format you need to use on whatever is consuming the XML.
You create the base XML using ogscript.parseXML. This function returns an org.w3c.dom.Document object. You can learn more about this object here:
https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Document.html
Here is an overall example of creating an XML document, adding information to it, and writing it back to a file:
<abs contexttype="opengear" style="">
<button buttontype="push" height="104" left="17" name="Write XML" top="18" width="160">
<task tasktype="ogscript">var xmlDoc = ogscript.parseXML('<?xml version="1.0" encoding="UTF-8"?><game/>');
var gameElement = xmlDoc.getDocumentElement();
var homeTeam = xmlDoc.createElement('home');
homeTeam.setAttribute('short', 'GG');
homeTeam.setAttribute('long', 'Good Guys');
homeTeam.setTextContent('Some Text Here');
gameElement.appendChild(homeTeam);
var awayTeam = xmlDoc.createElement('away');
awayTeam.setAttribute('short', 'BG');
awayTeam.setAttribute('long', 'Bad Guys');
awayTeam.setTextContent('Some More Text Here');
gameElement.appendChild(awayTeam);
ogscript.saveToFile('game-data.xml', gameElement, true);</task>
</button>
</abs>#DashBoard