• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using external XML document to update / change text fields inside of published captivate output.

New Here ,
May 04, 2015 May 04, 2015

Copy link to clipboard

Copied

Hello

I currently have a project where the client has requested to have the ability to update the text fields inside the project at a later date.

This is due to the nature of the content changing rather rapidly, i would like to set this up so the client can manage this them selfs.

What would the best way to do this be?

I'm thinking XML, an external XML sheet were by Captivate imports the text from this XML sheet and then displays it within the specific text fields contained within the captivate output.

This way the client would just update the external XML document(cut and paste the text in) and then the text would be dynamically updated in the published Captivate document.

any help would be amazing !

Thanks in advance

Nick

TOPICS
Advanced

Views

2.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
May 04, 2015 May 04, 2015

Copy link to clipboard

Copied

Not a bad approach except that there would be limits as to the amount of text they could use. If the text overflows the boundary of the text caption, it would get cut off.

Using XML: Common JavaScript Interface in Adobe Captivate 8 - YouTube

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2015 May 04, 2015

Copy link to clipboard

Copied

When having to translate text in Captivate, it is the only situation where I would check the option AutoSize Captions in the Preferences for that reason.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 04, 2015 May 04, 2015

Copy link to clipboard

Copied

Hi Lieve

But isn't this thread more about an end user having an ability to change text after the Captivate has been published and delivered? I could see where that might be useful if making changes then publishing to create a new output. But I'm interpreting that the situation here is that a Captivate project has been published and delivered, and some mechanism is desired that allows the recipient to modify an external XML file to influence changes in the already compiled Captivate output.

Cheers... Rick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2015 May 04, 2015

Copy link to clipboard

Copied

Sorry, Rick, indeed, I overlooked that.

If it is about just changing the content of variables, the problem with the size of text captions remains. And variable length is limited to 256 characters as well, probably sufficient in most cases.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 11, 2015 Nov 11, 2015

Copy link to clipboard

Copied

I've tried the the following js/xml code with no luck.  Has anyone got it functioning.  I have it on hosted on a google drive. It is not getting the xml data to the array.

Screen Shot 2015-11-11 at 12.31.22 PM.pngScreen Shot 2015-11-11 at 12.29.42 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

You are setting the value of newVarXml with "what" which is not a variable and if it is you would remove the quotes. what is also not defined in the code anywhere.

Also, when populating the array myArray in the loop, you are skipping the first index so you myArray[0] would not hold any value.

I've also found that Captivate does not like loops in the script window.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

"what" is the string that populates the newVarXml and will display on the screen so that line is working. You are correct that [0] is empty so the array should populate starting at[1]. The script runs and will show "what" from this line: window.cpAPIInterface.setVariableValue("newVarXml","what"); but when I try to populate the newVarXml variable from this line:  window.cpAPIInterface.setVariableValue("newVarXml", window.myArray[1]);  which is on another page it will go blank which tells me the is no information in the variable. So the XML data is not populating any of the array locations.  It should populate myArray[1] - [4].

On the other hand if it doesn't like the script window I guess I could insert it into the published file directly and see how that goes. The code was taken from the video referenced at the top of the page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

That's probably because myArray probably is not in the window, so you should not use a window preface, just use window.cpAPIInterface.setVariableValue("newVarXml", myArray[1]);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

Correct, that is the line that I have assigned on the second page and it displays a blank when called. For some reason the main script  is not pulling the data from the XML.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

What I was referencing is this line that you said that you used to populate the variable in Captivate:

window.cpAPIInterface.setVariableValue("newVarXml", window.myArray[1]);

You use window.myArray[1]

instead try:

myArray[1];

By the way, are you running this on a server? You need to be on a server to parse XML. You could just as easily create an array instead of an XML file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

Currently using google drive to host.  Waiting for our LMS to come on-line. https://googledrive.com/host/0BxgmDrlX4TzAR1Y5TEJtTjhqamc

Just trying to work this XML thing out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

The first page is the main script.  The second page buttons are calling the window.cpAPIInterface.setVariableValue("newVarXml", window.myArray[1]);  and I took out the window. and still the same results. I would assume that the google drive would work like an internal server but I could be mistaken. When the LMS is available I'll migrate to it and see what happens.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

I'm not sure how CP scopes the JavaScript window, but I would doubt that you can just call the array values without parsing the XML again.

If you were to put them in the index and call a function (getXML) you could at least control the Scope of the variables:

var myArray = new Array();

function getXML()
{

if ( window.XMLHttpRequest )
{
  xmlhttp = new XMLHttpRequest();
}
else
{
  xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
}

xmlhttp.open( "GET","stuff.xml", false );
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;

var x = xmlDoc.getElementsByTagName( "entity" );

for (var i = 0; i < x.length; i++)
{
  myArray[i + 1] = x.childnodes[0].nodeValue;
}

window.cpAPIInterface.setVariableValue("newVarXml", myArray[1]);
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

If all you are doing is setting the content of pages I would populate all variables at once when the loop is executing.

Are you outputting html5 or swf?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

HTML5

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 13, 2015 Nov 13, 2015

Copy link to clipboard

Copied

I would use the moduleReadyEvent in the index.html and when it fires loop through the array and set the page content variables.

I would create an XML doc with an entity for every slide whether it has content or not.

Create a variable (mySlide_1, mySlide_2, and so on) coinciding with the slide numbers.

window.addEventListener("moduleReadyEvent", function(evt)
{

interfaceObj = evt.Data;

eventEmitterObj = interfaceObj.getEventEmitter();

    getXML();

});

function getXML()
{

if ( window.XMLHttpRequest )
{
  xmlhttp = new XMLHttpRequest();
}
else
{
  xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
}


xmlhttp.open( "GET","stuff.xml", false );
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;

var x = xmlDoc.getElementsByTagName( "entity" );

for (var i = 0; i < x.length; i++)
{
  window.cpAPIInterface.setVariableValue("mySlide_"+(i+1), x.childnodes[0].nodeValue);
}
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 29, 2015 Dec 29, 2015

Copy link to clipboard

Copied

Hello Everyone,

Thanks for your answer TLCMediaDesign, it was really helpfull.

It work wonderfully on the html5 output.

However, i'm encountering some issue with the swf output

do you have any idea why it doesn't work ?

Thanks again for your help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 29, 2015 Dec 29, 2015

Copy link to clipboard

Copied

I would set an alert to see if the moduleReadyEvent is firing for swf.

If it isn't you could always run the JavaScript from the onEnter of the first slide.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 29, 2015 Dec 29, 2015

Copy link to clipboard

Copied

Actually i'm just using this part of the script :

if ( window.XMLHttpRequest )
{
  xmlhttp = new XMLHttpRequest();
}
else
{
  xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
}


xmlhttp.open( "GET","stuff.xml", false );
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;

var x = xmlDoc.getElementsByTagName( "entity" );

for (var i = 0; i < x.length; i++)
{

var slide = "mySlide_"+(i+1);
  window.cpAPIInterface.setVariableValue(slide, x.childnodes[0].nodeValue);
}

I've tried it on a button, and onEnter of the first slide.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 31, 2015 Dec 31, 2015

Copy link to clipboard

Copied

Change childnodes to childNodes, capitalize the "N"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 31, 2015 Dec 31, 2015

Copy link to clipboard

Copied

LATEST

Hello TLCMediaDesign

I've tried but withouth success.

Although thanks for your help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources