XML XPath Problem

0 favourites
  • 2 posts
  • 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!!!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)