Facility Control

 View Only
  • 1.  Bringing XML data into PanelBuilder

    Posted 02-18-2014 16:46
    Hi Everyone,

    I tried following instructions on another thread for bringing XML data into PanelBuilder and displaying it but have been unable to figure out the proper syntax.


    The XML file is very basic:



    -

    -


    -1

    Taylor



    -2

    Kyle



    -3

    Josh




    I created a button and started my ogScript with the below:

    var myXml = ogscript.parseXML('file:///C:/Users/jandrews/Desktop/testxml.xml');

    var first_set = ogscript.runXPath('/players', myXml);

    From this point I haven't been able to figure out how to utilize this data in my panel. What might be a basic framework I can use from here to display this information in a parameter or any other useful format? Any example syntax or reference would help me understand how to manipulate the data.

    I'm new to scripting and have only worked with PanelBuilder for a couple weeks. So far I have used it to control a scorebug and update graphics but I haven't worked with external sources like this. Ultimately I would like to use PanelBuilder to pull XML data in displaying lower third information.

    Thank you,

    Taylor


  • 2.  RE: Bringing XML data into PanelBuilder

    Posted 02-18-2014 17:01
    Hi Taylor,

    Your example doesn't look like XML, but plain text.

    XML would look something like:

    ...







    ...
    You can find basic and advanced info about authoring XML at W3 Schools

    Good luck!

    John

    #DashBoard


  • 3.  RE: Bringing XML data into PanelBuilder

    Posted 02-18-2014 17:03

    I know what happened - this forums tool strips out the angle brackets. My reply looks nothing like what I typed.

    I entered this using the "CODE" tab in the GUI. Let's see if it works...


    #DashBoard


  • 4.  RE: Bringing XML data into PanelBuilder

    Posted 02-18-2014 17:04
    nope!

    can you attach the file you want to read in? or even paste a screen grab of it?

    or email it to me directly: jnaylor@rossvideo.com

    J.

    #DashBoard


  • 5.  RE: Bringing XML data into PanelBuilder

    Posted 02-18-2014 22:30

    Here's a code sample that parses Taylor's XML example into a couple of array variables.

    var filepath = ogscript.getPrivateString('constants','filepath');
    
    var XMLDoc;
    
    ogscript.debug('Reading XML file: ' + filepath);
    
    XMLDoc = ogscript.parseXML(filepath);  // this line reads in the XML file, XMLDoc is set null on failure
    
    if (XMLDoc == null) {
    
         ogscript.debug('Failed to read file');
    
    } else {
    
       ogscript.debug('Parsing XML');
    
       var found=XMLDoc.getElementsByTagName('number');  // this line creates a nodeList
    
       ogscript.debug('search found ' + found.length + ' items');
    
       for (var i = 0; i < found.length; i++) { // for each item in the node list...
    
          var node = found.item(i);
    
          var children = node.childNodes;
    
          var num = children.item(0).nodeValue; // the zeroth will be the text node
    
          var name = children.item(1).firstChild.nodeValue // and the next will have the name data.
    
          ogscript.debug(i + ": " + name + ", " + num);
    
          params.setValue(0x2, i, name);
    
          params.setValue(0x3, i, Number(num));
    
       }

    John


    #DashBoard


  • 6.  RE: Bringing XML data into PanelBuilder

    Posted 02-18-2014 22:31
    thanks, WordPress, for removing all the indentation!

    #DashBoard