Sie sind nicht angemeldet.

1

Montag, 30. September 2019, 18:29

Is it possible to access custom xml node content?

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

Quellcode

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!

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »webseta« (30. September 2019, 18:59)


Mael B.

Schüler

Beiträge: 157

Wohnort: France, Montpellier

  • Nachricht senden

2

Montag, 30. September 2019, 20:43

Use this code instead:

Quellcode

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

Quellcode

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

3

Montag, 30. September 2019, 21:05

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.

Schüler

Beiträge: 157

Wohnort: France, Montpellier

  • Nachricht senden

4

Montag, 30. September 2019, 21:34

did you simply try (for your first example code)

Quellcode

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

5

Montag, 30. September 2019, 22:00

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

Beiträge: 1 117

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : the cms4vr owner

  • Nachricht senden

6

Dienstag, 1. Oktober 2019, 09:23

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 professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

7

Mittwoch, 2. Oktober 2019, 03:10

Thanks for the clarification.

8

Mittwoch, 2. Oktober 2019, 09:24

maybe webseta means something else...

using 'content' you cant access "hello":

Quellcode

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

but if you use attributes you can:

Quellcode

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


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

9

Mittwoch, 2. Oktober 2019, 15:52

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.