Explore the community Forums Lectora Online Lectora Online Questions & Answers Populate text boxes using strings pulled from external XML

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #436845 Score: 0
    Profile photo of Sam Higgins
    Sam Higgins
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    1 pt
    @shiggins.9138

    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

    #436885 Score: 0
    Profile photo of Joe Wieloch
    Joe Wieloch
    Moderator
    beginner
    intermediate
    friend finder
    contributor
    LUC16 Attendee
    verified member
    wise owl
    LUC17 Attendee
    advanced
    picture perfect
    53 pts
    @wheels

    I 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?

    #436887 Score: 0
    Profile photo of Sam Higgins
    Sam Higgins
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    1 pt
    @shiggins.9138

    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

    #436894 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    121 pts
    @mnotermans5114

    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?

    #436896 Score: 0
    Profile photo of Sam Higgins
    Sam Higgins
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    1 pt
    @shiggins.9138

    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

    • This reply was modified 1 month, 2 weeks ago by Profile photo of Sam Higgins Sam Higgins.
    #437185 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    121 pts
    @mnotermans5114

    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

    Attachments:
    1. Read-XML.pkg
    #437285 Score: 0
    Profile photo of Sam Higgins
    Sam Higgins
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    1 pt
    @shiggins.9138

    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

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.