28 Replies
Bort Bort

This will probably be a good start for anyone else trying to do this.

It will only work in HTML5 output for me, and as another user has mentioned, you can't set t/f variables properly in HTML5, which is a pain. So I'm using 0/1.


var player = GetPlayer();
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

xmlDoc.async="false";
xmlDoc.load("checklist.xml");
xmlObj=xmlDoc.documentElement;
var tag = xmlDoc.getElementsByTagName("PART")[0].attributes.getNamedItem("Checked").value;

if(tag === "True")
{
player.SetVar("variable", 1);
}
else
{
player.SetVar("variable", 0);
}

It's working for what I need it to do, and hopefully will help others.

edit: Here's an example of the XML to help anyone trying to work this out

<THING>

     <PART Checked="True" />

     <PART Checked="False" />

     <PART Checked="True" />

</THING>

Bort Bort

Here is what I sent to Dennis. May help others.

Here's the current js that I have on the slide that I want to show the results on. It runs on timeline start:

var player = GetPlayer();
 var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
 
 xmlDoc.async="false";

 xmlDoc.load("checklist.xml");
 xmlObj=xmlDoc.documentElement;
 
 var parts = xmlDoc.getElementsByTagName("PART");
 
 for (var t = 0; t < parts.length; t++)
 {
  if (parts[t].attributes.getNamedItem("Checked").value == "True")
  {
   player.SetVar(parts[t].attributes.getNamedItem("Tag").value, 1);
  }
  else
  {
   player.SetVar(parts[t].attributes.getNamedItem("Tag").value, 0);
  }
 }

Here's an example of the XML file contents:

<PARTS
 <PART Tag="Lights" Checked="False" /
 <PART Tag="Wheels" Checked="False" /
 <PART Tag="Boot" Checked="False" /
</PARTS

(I had to remove the closing tags in the XML as it wouldn't display)

Then on some graphics on the page, I have it working like this:

Change state of [graphic] to state [off] when [timeline starts] when [boot == 0.00]

or

Change state of [graphic] to state [on] when [timeline starts] when [boot == 1.00]

You can also just output the variables to a textbox like you have tried. You just need to make sure that you specify that in the javascript.

-----------------------

This may be more along the lines of what you need:

var player = GetPlayer();
 var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
 
 xmlDoc.async="false";

 xmlDoc.load("checklist.xml");
 xmlObj=xmlDoc.documentElement;
 
 var parts = xmlDoc.getElementsByTagName("PART");
 
 for (var t = 0; t < parts.length; t++)
 {
    player.SetVar(someVar, parts[0].attributes.getNamedItem("Tag").value);

 }

That will set someVar to the value of the first parts Tag value.

So looking at my XML, someVar would equal Lights.

-----

You can put the XML file anywhere, you just need to specify the address, somewhere online or within the folder structure, within the xmldoc.load function.

Graeme  Nicholls

Hi all

I have been working on this for some time and I have manage to get some pretty good results. In most browsers you will not be able to see the xml unless you have loaded it to a server somewhere (preferably the same one where the interaction is. Here is a copy of my javascript.

 Declare the XML node variables globally,

declare the player, xmlDoc and the xmlhttp globally 

var comp0="";

var comp1="";

var name0="";

var name1="";

var desc0="";

var desc1="";

var package0="";

var package1="";

var player=GetPlayer();

var xmlDoc="";

var xmlhttp="";

/* Request the xml doc from the server using the get method, file name and set asychronous to false.

Send the request and assign the resonse to the xmlDoc */

xmlhttp=new XMLHttpRequest();

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

xmlhttp.send();

xmlDoc=xmlhttp.responseXML;

/* select the first package node and scan it for < and replace it with and scan for / and replace it with /

This is done for each node retrieved. The final value is assigned to a variable pre-defined in the player.

The find and replace is done so that some formatting can be retrieved from the xml document since XSL/XSLT and CSS can't be used for formatting. */

package0=xmlDoc.getElementsByTagName("package")[0].childNodes[0].nodeValue;

var n=package0.replace(/</g,"

var x=n.replace(/>/g,">");

var y=x.replace(/./g,"/");

player.SetVar("Package1",y);

package1=xmlDoc.getElementsByTagName("package")[1].childNodes[0].nodeValue;

var n=package1.replace(/</g,"

var x=n.replace(/>/g,">");

var y=x.replace(///g,"/");

player.SetVar("Package2",y);

comp0=xmlDoc.getElementsByTagName("comp")[0].childNodes[0].nodeValue;

var n=comp0.replace(/</g,"

var x=n.replace(/>/g,">");

var y=x.replace(///g,"/");

player.SetVar("Competency1",y);

comp1=xmlDoc.getElementsByTagName("comp")[1].childNodes[0].nodeValue;

var n=comp1.replace(/</g,"

var x=n.replace(/>/g,">");

var y=x.replace(///g,"/");

player.SetVar("Competency2",y);

name0=xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;

var n=name0.replace(/</g,"

var x=n.replace(/>/g,">");

var y=x.replace(///g,"/");

player.SetVar("CompName1",y);

name1=xmlDoc.getElementsByTagName("title")[1].childNodes[0].nodeValue;

var n=name1.replace(/</g,"

var x=n.replace(/>/g,">");

var y=x.replace(///g,"/");

player.SetVar("CompName2",y);

desc0=xmlDoc.getElementsByTagName("description")[0].childNodes[0].nodeValue;

var n=desc0.replace(/</g,"

var x=n.replace(/>/g,">");

var y=x.replace(///g,"/");

player.SetVar("CompDescription1",y);

desc1=xmlDoc.getElementsByTagName("description")[1].childNodes[0].nodeValue;

var n=desc1.replace(/</g,"

var x=n.replace(/>/g,">");

var y=x.replace(///g,"/");

player.SetVar("CompDescription2",y);

And here is a copy of my XML file:

UEE11

UEENEEE107A

<b>Use Drawings, Schedules and Diagrams tested </b>

This unit covers the use of drawings, diagrams, cable schedules, standards, codes and specifications as they apply to the various electrotechnology work functions.<br />It encompasses:<br/>

<ul><li>the rudiments for communicating with schematic wiring and mechanical diagrams and equipment and cable/connection schedules manuals</li>

<li>site and architectural drawings and plans showing the location of services, apparatus, plant and machinery</li>

<li>understanding the use and format of compliance standards and job specifications.</li></ul>

BSB07

BSBWHS201A

<b>Contribute to health and safety of self and others (Release 1)</b>

This unit describes the performance outcomes, skills and knowledge required to participate in work health and safety (WHS) processes to protect own health and safety, and that of others.

Alsion DeRudder Thorpe

Ok - I get how this works with the XML but I am missing a basic piece of knoweldge to call that file up that I am hoping somebody can help me with.

I was able to get it to work on ONLY FF from my desktop. Not chome, not IE. Then, I loaded it up to a server. XML doesn't appear on any browser so this tells me I have done something wrong or need to reference it somewhere.

I think what I am missing is in here. Do I need to add the file location on the server in one of these commands somewhere? If so, where do I do that? If someone can show me what  i'm doing wrong, I think I can really use this. Thanks!

/* Request the xml doc from the server using the get method, file name and set asychronous to false.
Send the request and assign the resonse to the xmlDoc */
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","SAG.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
Indecomm Digital Services -  Development Team

Hi I am new to strotyline. I saw this post and i am trying to pull data from xml (for the transcript )into storyline text. Can anyone tell me where to keep .xml file in the folder structure?

Also it would be very helpful if some one provide me the working file if anyone has tried it before.

Ashley Terwilliger

Hi Pratik, 

Are you looking to use the translation feature of Storyline? That would allow you to export text that you currently have, and modify it to import in a new copy using the updated XML file. 

As Leslie mentioned earlier, the other method is not something we could support. 

Let me know if you need anything else! 

Deniz Yürür
pratik kanade

Hi I am new to strotyline. I saw this post and i am trying to pull data from xml (for the transcript )into storyline text. Can anyone tell me where to keep .xml file in the folder structure?

Also it would be very helpful if some one provide me the working file if anyone has tried it before.

I have the same problem. I can't find where to upload the xml file in file structure...