My Xml parse code is attached, not sure whats wrong

Get help using Construct 2

Post » Sat Oct 17, 2015 4:14 pm

I'm including both my actual Xml data and the code. The Messages2 text object never fills so the Xml is not parsing. The function is really getting the right Xml string so I'm not sure what I'm doing wrong.

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<game>
    <info>
        <name>Standard 52 Cards Game</name>
        <cardsize>
            <small width="73" height="98"></small>
            <large width="252" height="358"></large>
        </cardsize>
    </info>
    <cards>
        <card frame="0" name="Ace of Clubs" color="black" type="Clubs">Text</card>
        <card frame="1" name="Two of Clubs" color="black" type="Clubs">Text</card>
        <card frame="2" name="Three of Clubs" color="black" type="Clubs">Text</card>
        <card frame="3" name="Four of Clubs" color="black" type="Clubs">Text</card>
        <card frame="4" name="Five of Clubs" color="black" type="Clubs">Text</card>
        <card frame="5" name="Six of Clubs" color="black" type="Clubs">Text</card>
        <card frame="6" name="Seven of Clubs" color="black" type="Clubs">Text</card>
        <card frame="7" name="Eight of Clubs" color="black" type="Clubs">Text</card>
        <card frame="8" name="Nine of Clubs" color="black" type="Clubs">Text</card>
        <card frame="9" name="Ten of Clubs" color="black" type="Clubs">Text</card>
        <card frame="10" name="Jack of Clubs" color="black" type="Clubs">Text</card>
        <card frame="11" name="Queen of Clubs" color="black" type="Clubs">Text</card>
        <card frame="12" name="King of Clubs" color="black" type="Clubs">Text</card>
        <card frame="13" name="Ace of Spades" color="black" type="Spades">Text</card>
        <card frame="14" name="Two of Spades" color="black" type="Spades">Text</card>
        <card frame="15" name="Three of Spades" color="black" type="Spades">Text</card>
        <card frame="16" name="Four of Spades" color="black" type="Spades">Text</card>
        <card frame="17" name="Five of Spades" color="black" type="Spades">Text</card>
        <card frame="18" name="Six of Spades" color="black" type="Spades">Text</card>
        <card frame="19" name="Seven of Spades" color="black" type="Spades">Text</card>
        <card frame="20" name="Eight of Spades" color="black" type="Spades">Text</card>
        <card frame="21" name="Nine of Spades" color="black" type="Spades">Text</card>
        <card frame="22" name="Ten of Spades" color="black" type="Spades">Text</card>
        <card frame="23" name="Jack of Spades" color="black" type="Spades">Text</card>
        <card frame="24" name="Queen of Spades" color="black" type="Spades">Text</card>
        <card frame="25" name="King of Spades" color="black" type="Spades">Text</card>
        <card frame="26" name="Ace of Hearts" color="red" type="Hearts">Text</card>
        <card frame="27" name="Two of Hearts" color="red" type="Hearts">Text</card>
        <card frame="28" name="Three of Hearts" color="red" type="Hearts">Text</card>
        <card frame="29" name="Four of Hearts" color="red" type="Hearts">Text</card>
        <card frame="30" name="Five of Hearts" color="red" type="Hearts">Text</card>
        <card frame="31" name="Six of Hearts" color="red" type="Hearts">Text</card>
        <card frame="32" name="Seven of Hearts" color="red" type="Hearts">Text</card>
        <card frame="33" name="Eight of Hearts" color="red" type="Hearts">Text</card>
        <card frame="34" name="Nine of Hearts" color="red" type="Hearts">Text</card>
        <card frame="35" name="Ten of Hearts" color="red" type="Hearts">Text</card>
        <card frame="36" name="Jack of Hearts" color="red" type="Hearts">Text</card>
        <card frame="37" name="Queen of Hearts" color="red" type="Hearts">Text</card>
        <card frame="38" name="King of Hearts" color="red" type="Hearts">Text</card>
        <card frame="26" name="Ace of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="27" name="Two of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="28" name="Three of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="29" name="Four of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="30" name="Five of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="31" name="Six of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="32" name="Seven of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="33" name="Eight of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="34" name="Nine of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="35" name="Ten of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="36" name="Jack of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="37" name="Queen of Diamonds" color="red" type="Diamonds">Text</card>
        <card frame="38" name="King of Diamonds" color="red" type="Diamonds">Text</card>
    </cards
</game>


Image
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sat Oct 17, 2015 4:52 pm

just close node </cards
Image
B
64
S
23
G
7
Posts: 1,483
Reputation: 10,827

Post » Sun Oct 18, 2015 3:11 pm

@korbaach I was psyched for a few minutes, I thought you found the glitch. Sadly, no.

I see nothing wrong with this simple code. This is killing me.
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sun Oct 18, 2015 3:20 pm

locohost wrote:@korbaach I was psyched for a few minutes, I thought you found the glitch. Sadly, no.

I see nothing wrong with this simple code. This is killing me.


It does seem the code you provided is missing the > at the end of </cards
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Oct 18, 2015 3:25 pm

It says function param(0) is xmldata..

when are you calling this function and are you sure the data is actually in param(0)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Oct 18, 2015 3:44 pm

@LittleStain Yeah, with @korbaach helping I finally saw the </cards error. I thought for sure that was the problem. I made the fix and it still doesn't parse. Yes the Function.Param(0) definitely does have the Xml string. I can see it a variable in debug. And the Xml has the </cards> fix. I can't see why it won't parse. I may have to switch back to JSON. I can parse that for sure.
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sun Oct 18, 2015 4:18 pm

@locohost I copy your Xml code in text file and this is the result
Image
Image
Image
B
64
S
23
G
7
Posts: 1,483
Reputation: 10,827

Post » Sun Oct 18, 2015 4:30 pm

@korbaach Yeah I have it working now too. The issue was the </cards thing you found, plus I had a set of double-double quotes in the Xml start node. Fixed those two issues and it worked.

@korbaach
@LittleStain
Thanks a lot guys for getting me through this. Xml is a pain the ass :-/
Last edited by locohost on Sun Oct 18, 2015 4:34 pm, edited 1 time in total.
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Sun Oct 18, 2015 4:32 pm

Wish I would have found (or thought of looking for) this sooner...

http://www.xmlvalidation.com/
B
13
S
4
Posts: 280
Reputation: 1,573


Return to How do I....?

Who is online

Users browsing this forum: RobertMKD, tarek2 and 9 guests