Trouble with XML parsing

0 favourites
  • 5 posts
  • 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: ... #ad-output

    (5) my xml file is appropriately added as a project file.

    [attachment=0:17dq3yc0]xml example.PNG[/attachment:17dq3yc0]

    [attachment=1:17dq3yc0]construct 2 example event sheet.PNG[/attachment:17dq3yc0]

  • Have you looked at this:

  • 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.


    for better viewing, here's the raw XML:

    "<?xml version=""1.0"" encoding=""utf-8""?>


    <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 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>



  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • Ok I'll try that out. TY Blackhornet

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