You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

herrpedro

Trainee

  • "herrpedro" started this thread

Posts: 134

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

1

Tuesday, September 25th 2018, 10:37pm

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

2

Wednesday, September 26th 2018, 10:22pm

You can use this example, hope it will work.

<data name="css_def">
<![CDATA[
write smth here
]]>

</data>

herrpedro

Trainee

  • "herrpedro" started this thread

Posts: 134

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

3

Wednesday, September 26th 2018, 11:00pm

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>

4

Friday, September 28th 2018, 10:42pm

Hi,

the <data> element is a special one, it's inner content doesn't get parsed, it will be stored as data[name].content.

Please see here for more:
https://krpano.com/docu/xml/#data

If you want to access the xml-parsed and to objects resolved elements use an other name for your xml element, e.g. <mydata>.

Best regards,
Klaus

herrpedro

Trainee

  • "herrpedro" started this thread

Posts: 134

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

5

Friday, September 28th 2018, 10:43pm

hi!

that really really explains it.

thank you for your help

6

Sunday, September 30th 2018, 10:29pm

Hi herrpedro,

Last year I posted my solution of multilanguage version of krpano here:
https://krpano.com/forum/wbb/index.php?p…5255&highlight=

It was done for the krpano ver 1.19.pr13. I do use it since then though I am planning to upgrade the code for the ver. 1.19.pr16. It's working as is in the ver. 1.19.pr16, too.
e.g. here
Some guys downloaded it but no feedback. Maybe you will be the first one.

Enjoy,
Pavel

herrpedro

Trainee

  • "herrpedro" started this thread

Posts: 134

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

7

Sunday, September 30th 2018, 10:41pm

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

8

Sunday, September 30th 2018, 11:13pm

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