How do I load an xml string with AJAX.LastData?

Get help using Construct 2

Post » Fri Jan 15, 2016 7:39 pm

Hi,
I just tried to load my xml string via AJAX.LastData but it seems that I can't get it working. I tried many different things that I found in the forums and in tutorials... but it doesn't work.
I want to get the values out of this xml string:

<?xml version="1.0" ?>
<xml>
<item>
<property>

<id>1</id>

<type>type</type>

<name>name</name>

</property>
</item>
</xml>

And I'm using this to get it:

XML.StringValue("/xml/item/property/id/text()") <----- In this case I should get 1 I think

But that returns nothing. :/
What did I do wrong? Is something with the xml file wrong?
Thanks! :)
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Fri Jan 15, 2016 9:37 pm

Make sure there is no white-space before the xml. Just having one space before the "<" bracket will cause it t fail. I just tried a hard code test with your example and it does work, but with anything before the xml, it won't.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Sat Jan 16, 2016 1:34 pm

Thanks @blackhornet!
I'll see if I have any white spaces before the xml.
Thanks again!
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Sat Jan 16, 2016 2:37 pm

It works now! :D
Thanks!
Image
B
5
S
3
Posts: 193
Reputation: 1,063


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, cb130felix, Kermad, Lancifer, nyuszi008, tarek2 and 8 guests