parsing and accessing custom XML

  • hi all


    i have some items showing in a vtour.
    i'm making it multilanguage so i need several string according to language so i thought of a xtructure like this
    accessing "data" is easy data[nameOne] will do it
    data[nameOne].content will give me the inside
    data[nameOne].sound will give me the sound

    but i can't find a way to access the language node so i cent get the .content inside (and have my string)
    <language name="pt">
    portugues
    </language>


    <data name="nameOne" sound="somesound" video="somevideo" photo="somephoto">
    <language name="pt">
    portugues
    </language>
    <language name="en">
    english
    </language>
    <language name="es">
    espanõl
    </language>
    </data>

    <data name="nameTwo" sound="somesound" video="somevideo" photo="somephoto">
    <language name="pt">
    portugues
    </language>
    <language name="en">
    english
    </language>
    <language name="es">
    espanõl
    </language>
    </data>

    thank you for the help

  • hi!
    thank you for your 1st post :) welcome

    i want something like data[nameOne].xml.language[pt].content or something like this <- edited: does not work either
    so i can read the string "portugues" from that xml
    i never tried this one.. i'll try it now :)

    <data name="nameOne" sound="somesound" video="somevideo" photo="somephoto">
    <language name="pt">
    portugues
    </language>
    <language name="en">
    english
    </language>
    <language name="es">
    espanõl
    </language>
    </data>

  • hi,

    thank you for your reply,

    i did read your post while working on this and searching the forum, i did it more than once actually

    The thing is i'm after more than "translation".. i'm setting up hotspots and actions and dynamic hotspots based on that
    like "youtube movie id" associated with language
    or mp3 audio file associated to language

    i managed to parse it already with klaus hint
    now i'm having trouble with "defaults" or "fallback"

    like.. if i want a "youtubeid" from a element i'm having trouble with "if" statements determining if a variable is there or not

    if i want a sound i'll say "give sound associated with mydata[nameone] for english-UK"

    the action will
    see if there is a sound atribute associated with language en-uk
    if not - see if there is a sound atribute associated with language for en
    if not - see if there is a sound associated with the mydata element
    if not.. return null

    i cant do it with if === null or if != null or... tried so many variants i cant tell them all :D  
    so far i'm defaulting to
    -> see if there is a sound atribute associated with language for en
    and so i'm must be aware to fill in the xml for all languages (instead of only the top one if the string is the same for every one)

    again, thank you for your help

  • The new calc() function is really a powerful instrument!
    I use it a lot e.g.
    set( element,
    attribute1=calc( isworking == true ? 'text1' + variable1 : 'text2' + variable2),
    attribute2=calc( myHight LE 6 ? true : false),
    ...
    );
    You can nest the trinary operator, but the readibility of the code goes down.
    I'm learning a lot from Klaus' 1.19.pr16 example of the combobox.xml. Thank you, Klaus for such a great lesson!

    Pavel

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!