Skip to main content
Inspiring
March 6, 2016
Question

Reading variable data from XML file

  • March 6, 2016
  • 1 reply
  • 1560 views

Greetings all!

I am trying to discover if (and if, how) to read variable data from an XML file and assign that data to Captivate variables for use within a project. Anyone know the answer to this riddle?

Thank you

    This topic has been closed for replies.

    1 reply

    Inspiring
    March 6, 2016

    Here is a video from Adobe on using XML in Captivate:

    Common JavaScript Interface in Adobe Captivate 8 - YouTube

    They had the project from the YouTube video available for download in the past but I can't find it now.

    Here is how I interpreted the video to use it on Entering a slide. I populate the 6 book variables with the XML data:

    var myBookArray = new Object();

    xmlhttp=new XMLHttpRequest();

    xmlhttp.open("GET","Assurance.xml",false);

    xmlhttp.send();

    xmlDoc=xmlhttp.responseXML;

    var a=xmlDoc.getElementsByTagName("proBook");

    for (i=0;i<a.length;i++)

      {

      var at = a.attributes;

      myBookArray[i+1] = a.childNodes[0].nodeValue;

      }

    window.cpAPIInterface.setVariableValue("book1", window.myBookArray[1]);

    window.cpAPIInterface.setVariableValue("book2", window.myBookArray[2]);

    window.cpAPIInterface.setVariableValue("book3", window.myBookArray[3]);

    window.cpAPIInterface.setVariableValue("book4", window.myBookArray[4]);

    window.cpAPIInterface.setVariableValue("book5", window.myBookArray[5]);

    window.cpAPIInterface.setVariableValue("book6", window.myBookArray[6]);

    HTH