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.

1

Monday, September 30th 2019, 6:29pm

Is it possible to access custom xml node content?

When there is a custom-defined xml node, something like this:

Source code

1
2
3
4
5
6
7
8
9
<krpano>
	<node>
		<subnode name="a">asdasd</subnode>
		<subnode name="b">qweqwe/subnode>
		<subnode name="c">asdasd</subnode>
		<subnode name="d">qweqwe</subnode>
		<subnode name="e">asdasd</subnode>
	</node>
</krpano>


Is it possible to access the contents of the nodes, so in the above example the "asdasd" and "qweqwe" texts? I know there is the <data> module, but I'm interested to know if it is possible to do it this way...thanks!

This post has been edited 1 times, last edit by "webseta" (Sep 30th 2019, 6:59pm)


Mael B.

Trainee

Posts: 155

Location: France, Montpellier

  • Send private message

2

Monday, September 30th 2019, 8:43pm

Use this code instead:

Source code

1
2
3
4
5
6
7
8
9
<krpano>
	<node name="mynode" >
		 <subnode name="a" content="asdasd" />
		<subnode name="b" content="qweqwe" />
		<subnode name="c" content="asdasd" />
		<subnode name="d" content="qweqwe" />
		<subnode name="e" content="asdasd" />
	</node>
</krpano>


And so you get the content of the subnode with

Source code

1
get(node[mynode].subnode[a].content)

3

Monday, September 30th 2019, 9:05pm

Thanks a lot, but I already knew that. I was specifically interested to know if there's a way to read the node's content, instead of an attribute :P

Mael B.

Trainee

Posts: 155

Location: France, Montpellier

  • Send private message

4

Monday, September 30th 2019, 9:34pm

did you simply try (for your first example code)

Source code

1
get(node.subnode[a].content)

5

Monday, September 30th 2019, 10:00pm

I did, and it doesn't work like that, I guess that only works for <data> and <action> nodes.

spacerywirtualne

Professional

Posts: 997

Location: Poland, Europe

Occupation: krpano developer : virtual tours

  • Send private message

6

Tuesday, October 1st 2019, 9:23am

Hi,

Some time ago, Klaus answered the same question that I can't get to node CONTENT except data[name].content.

I don't think anything has changed here. The only solution is pure Javascript or jQuery.


Piotr
Your own online, cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube

cms4vr team *thumbsup*

7

Wednesday, October 2nd 2019, 3:10am

Thanks for the clarification.

8

Wednesday, October 2nd 2019, 9:24am

maybe webseta means something else...

using 'content' you cant access "hello":

Source code

1
2
3
<node>
	<subnode name="a">hello</subnode>
</node>

but if you use attributes you can:

Source code

1
2
3
<node>
	<subnode name="a" value1="hello" value2="world" />
</node>


trace(node.subnode[a].value1, ' ', node.subnode[a].value2);
--> hello world

9

Wednesday, October 2nd 2019, 3:52pm

No, my interest was specifically in accessing content, because some type of data is better stored as node content, and not attributes. But I can use <data> nodes for that, it would have been ideal if it could have been done with custom nodes too, but alas, it can't.