How do I load the following XML...

0 favourites
  • 10 posts
  • Hello community,

    I am having trouble loading the XML below through the XML object. On import, i get multiple syntax errors and it will not load. On paper it seems to be a straight forward process but i might be missing something. Ashley , Yann Can you please confirm if this XML can be imported through the native XML object. If not, is there an alternative way to grab the data. The goal is for the hosted game to load the xml from an URL on runtime, grab and parse the data. Thank you in advanced for the assistance provided...

    <?xml version="1.0"?>
    <words>
    <meta>
    <user_id>85826</user_id>
    <word_order>e</word_order>
    </meta>
    <word>
    <word>
    <![CDATA[ flip-flop ]]>
    </word>
    <definition>
    <![CDATA[ a thonged sandal and its clicking sound ]]>
    </definition>
    <wordid>
    <![CDATA[ 367925 ]]>
    </wordid>
    <sentenceid>
    <![CDATA[ 653737 ]]>
    </sentenceid>
    <soundfile>
    <![CDATA[ /sounds/f/flip_flop.mp3 ]]>
    </soundfile>
    <definitionfile>
    <![CDATA[ /definitionSounds/f/flip-flop_50d41874a9c93.mp3 ]]>
    </definitionfile>
    <definition_option id="460293" soundfile="/sounds/s/st_.mp3">
    <![CDATA[ St. ]]>
    </definition_option>
    <definition_option id="310953" soundfile="/sounds/i/it_s.mp3">
    <![CDATA[ it's ]]>
    </definition_option>
    <definition_option id="653737" soundfile="/sounds/f/flip_flop.mp3">
    <![CDATA[ flip-flop ]]>
    </definition_option>
    </word>
    <word>
    <word>
    <![CDATA[ it's ]]>
    </word>
    <definition>
    <![CDATA[ contraction of "it is" ]]>
    </definition>
    <wordid>
    <![CDATA[ 13637 ]]>
    </wordid>
    <sentenceid>
    <![CDATA[ 310953 ]]>
    </sentenceid>
    <soundfile>
    <![CDATA[ /sounds/i/it_s.mp3 ]]>
    </soundfile>
    <definitionfile>
    <![CDATA[ /definitionSounds/i/it_s_50cb3fe723f2d.mp3 ]]>
    </definitionfile>
    <definition_option id="653737" soundfile="/sounds/f/flip_flop.mp3">
    <![CDATA[ flip-flop ]]>
    </definition_option>
    <definition_option id="310953" soundfile="/sounds/i/it_s.mp3">
    <![CDATA[ it's ]]>
    </definition_option>
    <definition_option id="460293" soundfile="/sounds/s/st_.mp3">
    <![CDATA[ St. ]]>
    </definition_option>
    </word>
    <word>
    <word>
    <![CDATA[ St. ]]>
    </word>
    <definition>
    <![CDATA[ abbreviation for "street" ]]>
    </definition>
    <wordid>
    <![CDATA[ 29966 ]]>
    </wordid>
    <sentenceid>
    <![CDATA[ 460293 ]]>
    </sentenceid>
    <soundfile>
    <![CDATA[ /sounds/s/st_.mp3 ]]>
    </soundfile>
    <definitionfile>
    <![CDATA[ /definitionSounds/s/St._50cb531accd9f.mp3 ]]>
    </definitionfile>
    <definition_option id="653737" soundfile="/sounds/f/flip_flop.mp3">
    <![CDATA[ flip-flop ]]>
    </definition_option>
    <definition_option id="310953" soundfile="/sounds/i/it_s.mp3">
    <![CDATA[ it's ]]>
    </definition_option>
    <definition_option id="460293" soundfile="/sounds/s/st_.mp3">
    <![CDATA[ St. ]]>
    </definition_option>
    </word>
    </words>[/code:3dvumhzi]
  • If you are loading through the C2 GUI, all quotes have to be doubled.

  • As blackhornet said.

    Also, I do have some XML file in a project as project file (so through AJAX, not directly inserted into C2's field) and comments starts with <!-- and close with --> in it.

    You might want to check that out as well.

  • You should definitely import files as project files and request them via AJAX. Pasting large amounts of data in to expressions has significant pitfalls and also requires extensive escaping of the data to stop the double-quotes ending the string, which is a really tedious problem to fix.

  • Thanks for the assistance blackhornet & Ashley . Unfortunately, the project requires that the XML loads through an URL as there are 100's based on the game category and they are generated through an API.

    Kyatric Where can i find the XML project you mentioned?. I search through the forums and tutorials with no luck. Can you point me to the right location. It appears that it will assist me with the parsing of the data...

  • The XML file is part of a project of mine, it's not public.

    Project files though are talked about in this tutorial.

  • As a side note, the XML can indeed be loaded inside the official XML plugin. Just tried it !

  • Thanks Kyatric i will look again at this tutorial.

    Magistross, can you please share how you were able to do it? I was able to import the data through the AJAX object but have not been able through the official XML plugin directly . Is it possible for you to upload the .CAPX. to share with the community. I would be thankful as i know this has come up on many instances in the forum...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sure, here it is.

    https://dl.dropboxusercontent.com/u/700 ... adXML.capx

    As an exemple, I displayed the first <word> node of the first <word> node. Strange document structure by the way, but I guess it's out of your control... <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz">

  • Thank you Magistross for taking the time to upload the sample and for everyone else who assisted. I was able to find a solution by using both the AJAX and XML object as shown.

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