Facility Control

 View Only
  • 1.  Generating XML data

    Posted 01-12-2017 18:08
    Can my score control panel also create an XML file of the score data? For example: we would like to create an XML that is taking the team names, clock and score data and publish it to a could-based storage site.

    Thanks!
    Brian


  • 2.  RE: Generating XML data

    Posted 01-12-2017 20:25
    When you create a new custom panel you can select "External XML Data Source Panel" and this will create an XML file for the data. This is what Dashboard then pulls from too and must be in the same file path as the dashboard file.
    #DashBoard


  • 3.  RE: Generating XML data

    Posted 01-12-2017 20:59
    I don't suppose there's a way to do both? I don't need to send all of the Dashboard data I'm generating to the XML file.
    #DashBoard


  • 4.  RE: Generating XML data

    Posted 01-12-2017 21:46

    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('&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;game/&gt;');
    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


  • 5.  RE: Generating XML data

    Posted 01-12-2017 23:06
    Thanks James - I'll give it a shot. I don't need everything going into the XML, so this may work.
    #DashBoard