What am I doing wrong here?

Get help using Construct 2

Post » Fri May 03, 2013 5:33 pm

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!
B
8
Posts: 22
Reputation: 944

Post » Fri May 03, 2013 7:05 pm

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.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Fri May 03, 2013 8:56 pm

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?
B
8
Posts: 22
Reputation: 944

Post » Fri May 03, 2013 9:24 pm

Sure, just use
[code]XML.StringValue("/rows/row[" & variable & "]/PowerName/text()")[/code]
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Fri May 03, 2013 9:26 pm

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
B
8
Posts: 22
Reputation: 944

Post » Fri May 03, 2013 10:16 pm

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
B
8
Posts: 22
Reputation: 944


Return to How do I....?

Who is online

Users browsing this forum: anty21ro, Yahoo [Bot] and 13 guests