Populate text boxes using strings pulled from external XML

shiggins-9138
Community Member Posts: 9
Hi all
Is it possible to attach an external XML to a title and use JavaScript to pull strings from it into text boxes on the stage? If so, what is the best way to embed the XML into the title and parse it into the JS? This is for LMS integration, if it makes any difference.
Small words and simple steps appreciated
Thanks in advance
Is it possible to attach an external XML to a title and use JavaScript to pull strings from it into text boxes on the stage? If so, what is the best way to embed the XML into the title and parse it into the JS? This is for LMS integration, if it makes any difference.
Small words and simple steps appreciated
Thanks in advance
Comments
-
wheels Florida USACommunity Member, Administrator, Moderator, Rockstar Manager Posts: 665 eLearning ROCKSTAR Admin TeamI feel it might help if you start with what you are trying to achieve / what problem are you trying to solve.
Here is a REALLY OLD video talking about dynamic text:
https://www.trivantis.com/elearning-save-time-dynamic-text
The idea is the same and we still have this feature, maybe this will be enough? -
Thanks Joe
The aim is to create several language versions all contained within the same title where the text content can be populated based on the language choice and text updates can be made quickly to each version. I have seen the dyntitle.xml but I'm looking for a more user-friendly method (that file is particularly difficult to navigate quickly), where the text could be laid out like this...
<Page1>
<txt_1>
<en>This box is first</en>
<es>Es la primera</es>
<fr>Celui-çi la boîte première</fr>
</txt_1>
<txt_2>
<en>This box is second</en>
<es>Es la secunda</es>
<fr>Celui-çi la boîte deuxième</fr>
</txt_2>
</Page1>
...from which the JavaScript could select the appropriate content.
My problem is that I can't seem to work out how to link the XML file to my JS through the Lectora storage
Thanks again -
Better use JSON or actually a database to get the texts. Have what you talk about working... using text from an external database ( actually from Google Slides ) Its my new workflow that makes completely dynamic titles, so indeed you can use it to create 1 title with any amount of languages ( actually even replace images with localized texts where and when needed )
Alas i cannot share this as is...but i probably can make a sample for you that does this..
What lectora version are you working in? -
Thanks for the suggestion, Math.
We have considered JSON but we're not too familiar with it and XML would be much more in line with our current working style for the time being, so if it's achievable that way it would be preferable.
The version, however, is Lectora Online 4.5
Thanks again, though -
Created a simple setup that reads data from XML... as of cross-origin security i had to add it to my own site to test.
With CORS you should be able to read it from anywhere...
Here you see it working...
http://www.mathnotermans.nl/TrivantisCommunity/
And the Lectora Online package added...
Regards,
Math -
Hi Math
Many thanks for this, although I keep getting this error:
[readXMLFile( _path )] NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://www.mathnotermans.nl/TrivantisCommunity/data_simple.xml'.
I've tried allowing for loading time, too, but still no luck.
On another note, we've actually managed to put something in place ourselves in the Lectora title, but for some reason it seems to work in the Single Page Preview but not once exported, when we get this error:
TypeError: Cannot set property 'innerHTML' of undefined
Is there something in the wider package that would be causing this?
Thanks again for your help
Categories
- 35.8K All Categories
- 108 ✫ Announcements
- 33.1K Lectora®
- 31.1K Lectora Discussions
- 28.9K Lectora Desktop
- 2K Lectora Online
- 2K Lectora Feature Requests
- 71 Lectora User Groups
- 36 Lectora Accessibility User Group (LAUG)
- 22 ELB Learning Content
- 22 ELB Learning Content Discussions
- 321 CenarioVR®
- 188 CenarioVR Discussions
- 133 CenarioVR Feature Requests
- 41 Rockstar Learning Platform®
- 38 Rockstar Learning Platform Discussions
- 108 CourseMill®
- 108 CourseMill Discussions
- 47 ReviewLink®
- 47 ReviewLink Discussions
- 5 The Training Arcade®
- 5 The Training Arcade Discussions
- 934 All Things eLearning
- 36 eLearning Development
- 546 Learning Management System (LMS) Integration
- 332 Web Accessibility
- 1.2K ♪ The Green Room
- 9 Additional Learning Products