Trouble with XML parsing

Get help using Construct 2

Post » Fri Jul 18, 2014 3:08 pm

Hey everyone!

I've been looking at some of the XML parsing examples and either they don't work or have extensive hand editing. Below you'll find my construct 2 example and the example xml.

Some notes:
(1) the G_ENT_## are global variables as I'm moving my enemies through sets of arrays. The global variables help maintain the index values and are easy constant references.
(2) when I run my program in debug mode, the XML data is sitting in the AJAX object.
(3) Nothing ever gets written to the array arrNPCEnemies.
(4) I'm using this site to test my xpath queries: http://www.freeformatter.com/xpath-test ... #ad-output
(5) my xml file is appropriately added as a project file.

xml example.PNG


construct 2 example event sheet.PNG
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 5
Reputation: 211

Post » Fri Jul 18, 2014 3:23 pm

ImageImageImage
B
71
S
21
G
230
Posts: 3,688
Reputation: 128,847

Post » Fri Jul 18, 2014 4:21 pm

I have. You'll notice in the copied XML that there are double quotes, which is non-standard for XML. That means I have to manually edit the xml file every time I update it.

doublequotes.PNG


for better viewing, here's the raw XML:

"<?xml version=""1.0"" encoding=""utf-8""?>
<Catalog>
<Album artist=""The Last Shadow Puppets"" title=""The Age Of The Understatement"">
<Track rating=""4"" length=""P3M7S"">The Age Of The Understatement</Track>
<Track rating=""3"" length=""P2M18S"">Standing Next To Me</Track>
<Track rating=""5"" length=""P2M26S"">Calm Like You</Track>
<Track rating=""3"" length=""P3M38S"">Separate and Ever Deadly</Track>
<Track rating=""2"" length=""P2M37S"">The Chamber</Track>
<Track rating=""3"" length=""P2M44S"">Only The Truth</Track>
</Album>
<Album artist=""Kings Of Leon"" title=""Because Of The Times"">
<Track rating=""4"" length=""P7M10S"">Knocked Up</Track>
<Track rating=""2"" length=""P2M57S"">Charmer</Track>
<Track rating=""3"" length=""P3M21S"">On Call</Track>
<Track rating=""4"" length=""P3M09S"">McFearless</Track>
<Track rating=""1"" length=""P3M59S"">Black Thumbnail</Track>
</Album>
</Catalog>"
You do not have the required permissions to view the files attached to this post.
Last edited by jaytwining on Fri Jul 18, 2014 4:37 pm, edited 1 time in total.
B
5
Posts: 5
Reputation: 211

Post » Fri Jul 18, 2014 4:36 pm

That's only if you are copying the XML into C2, which requires the double quotes. Here's the same thing read in from a project file. AJAX can also grab it from a server, if that's what you need.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
21
G
230
Posts: 3,688
Reputation: 128,847

Post » Fri Jul 18, 2014 4:38 pm

Ok I'll try that out. TY Blackhornet
B
5
Posts: 5
Reputation: 211


Return to How do I....?

Who is online

Users browsing this forum: fnfhjfdbdjbfbfd, luckyrawatlucky, marcinkowski, plinkie and 20 guests