XML is a godsend

0 favourites
  • 9 posts
  • Awesome new release, guys! Funny enough, I was hoping for XML support for reading text from a file; just what I needed for a text-based game! However, how do you get it to work? I feel kinda dumb asking, but how do you get the text file to read your XML file? Or do you import the XML file into the project? I'm a little lost. <img src="smileys/smiley9.gif" border="0" align="middle" />

  • Try using the AJAX object to request an XML file, then load it in 'On completed' by loading AJAX.LastData in the XML object.

  • Please please please make a json object capable of traversing complex objects! If not, I'll have to make one (that uses expressions like jquery) myself :(

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Uhh...I think I'm still a bit lost. I have a sample XML file:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <script scene="ep01_scene01">
         <main_line line="1">
              <text>Wakka wakka, folks!</text>
         <main_line line="2">
              <queue choice="1"></First>
              <queue choice="2"></Second>
              <queue choice="3"></Third>
              <text choice="1">I am saying the first selection.</text>
              <text choice="2">I am making the second selection.</text>
              <text choice="3">The third selection is mine to make!</text>

    I have an AJAX object in my scene, and I make the request on start of layout. In fact, here is my event sheet:

    <img src="http://dl.dropbox.com/u/12274890/Capture.JPG" border="0" />

    Thing is, I'm a bit confused as to what I should be doing here.

  • Event 10 => Load XML document from string AJAX.LastData

  • Sharpshooter, where you have the "????", have you tried entering AJAX.LastData there?

    And yep, this is most definitely an awesome addition to C2, so much simpler having it all built into the core.

    [Looks like Kyatric got to it just a minute before I did, must've been right as I was reading it!]

  • Ok, I got that. The last question I have is how do I get the text object to be set to a specific node in the xml file?

  • You have to use XPath - try looking up a tutorial on it.

  • Well, I understand the XPath part. What I'm having trouble with is how you get Construct to actually recognize when I call a node; my issue is that I just don't understand where I put the expressions for XPath; do I just stick them in the "set text to" area or...?

    I am confused in making the XML file communicate with Construct 2.

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