XML XPath Problem

Get help using Construct 2

Post » Fri Jun 13, 2014 9:21 pm

I'm having an odd problem with XML. I am trying to view a node in a text box.

If I do a node count of my XML like this:
Levels.NodeCount("/levels/level[1]/scene[1]/flower[1]/state")

I get a node count of 1, which is correct as there is a <state>hidden</state> at that node location.

But, if I do this:
Levels.StringValue("/levels/level[1]/scene[1]/flower[1]/state")

I do not get the text ("hidden") from the node. I just get nothing back at all.

I also tried using /state[text()] which should get the text from the node, but that doesn't work either.

Am I missing something in the way that C2 handles xpath?

Thanks for any help!!!
B
7
S
2
Posts: 4
Reputation: 582

Post » Thu Jun 19, 2014 9:25 pm

I found the answer. To get the text from the state node you write it like this:

Levels.StringValue("/levels/level[1]/scene[1]/flower[1]/state/text()")

Hope this will help someone else who gets stuck!
B
7
S
2
Posts: 4
Reputation: 582


Return to How do I....?

Who is online

Users browsing this forum: lukewasthefish, marc254, Mayfly, Yahoo [Bot] and 17 guests