What am I doing wrong here?

  • Hi all,

    I am trying to have a project load an XML project file and then be able to parse data from that XML data. So far so good it seems. I've read the manual, I've read all the XML tutorials, I've read up on XPATH. What I'd really like is if someone could could show me where I am wrong combining Construct 2 expressions with XPATH. Specifically, I am trying to call up the first string with a specific tag.

    Here's my project

    I am using the expression XML.StringValue("/rows/row/PowerName[1]") and I am immediately noticing two issues: Only the first word in the string is appearing, if I replace [1] with [2] nothing loads despite there being 3 items. A little help would be much appreciated.

    Thanks!

  • It's actually printing "Heavy SlashRunthroughDefensive Strike" but the text area is too small to display it all.

    I think you want "/rows/row[1]/PowerName" or "/rows/row[1]/PowerName/text()".

    Internet Explorer needs the "/text()" on the end.

  • Awesome, that works great. I do have a follow up question. Is there a way to replace the [1] with a check on an Instance Variable?

  • Sure, just use

    XML.StringValue("/rows/row[" & variable & "]/PowerName/text()")
  • I could kiss you. *ahem* But, I'll refrain from doing so. Seriously though, thanks for the help. I have been stumped on this for a couple of weeks now. You've been tremendously helpful.

    Regards,

    PZ

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • One (hopefully) final question. Is there a way to format text in an expression?

    Here's what I am trying to do specifically:

    Here's my expression: "Requirements: " & XML.StringValue("/rows/row[" & SkillBox1.NodeValue & "]/Requirements/text()") & newline

    I'd like the first piece of text "Requirements: " to be bold. Is that possible?

    Thanks,

    Phil Z

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