User Tag List

Results 1 to 10 of 10

Thread: How do I get the data off of an XML document?

  1. #1
    No Products Registered

    Join Date
    Nov 2006
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I get the data off of an XML document?

    Hello,

    I'm unsure (and somewhat confused) how to get the data off of an XML document. Here's a piece of the file I have:

    <movement>
    <speed>20</speed>
    <acceleration>225</acceleration>
    <deceleration>225</deceleration>
    <roll_anim>27<roll_anim>
    <roll_time>0</roll_time>
    <jump>-20</jump>
    <special_anim>15</special_anim>
    <special_value>90</special_value>
    </movement>
    <battle>
    <power>0</power>
    <defence>0</defence>
    <charge_time>0</charge_time>
    <energy_use>0</energy_use>
    </battle>

    How would I take those various values in the XML document from the XML document? Also, is the method for getting the values different compared to the method for getting text? Note: I do have a single root element, but it is not shown in the section of the file I have shown in this post.

    Thanks for your help,

    Neonotso

  2. #2
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export Module
    DavidN's Avatar
    Join Date
    Jun 2006
    Location
    Boston, MA, USA
    Posts
    4,044
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I get the data off of an XML document?

    You need one single root tag (at least, you usually do - I'm not certain if either of the available XML extensions enforce this). After that, use an extension like EasyXML to explore the tree.

  3. #3
    No Products Registered

    Join Date
    Nov 2006
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I get the data off of an XML document?

    Okay, I do have a single root tag. I just didn't show it in the portion of the file I showed in my previous post. I guess my main question is, How do I use EasyXML to get the data off of the file?

  4. #4
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    England
    Posts
    3,546
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)

    Re: How do I get the data off of an XML document?

    To quote Wikipedi: "Each XML document has one, and exactly one single root element. This element is also known as the document element. It encloses all the other elements and is therefore the sole parent element to all the other elements."

    So basically all of the elements need to be a child of the root element. For example HTML documents (web pages) all start with <HTML> and end with </HTML> because HTML is the root (top-level) element. The only data before the root element is metadata such as document type, XML version or character encoding.
    .:::.Joshtek.:::.

  5. #5
    No Products Registered

    Join Date
    Nov 2006
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I get the data off of an XML document?

    I do have a single root element, but I suppose I should have actually displayed it in the first post (I only displayed a section of the document) to avoid this confusion. Thanks, though.

    Here's how the document would look with one character profile in it (with the password area modified as to not reveal the password):

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <profiles>
      <player id="NV7">
        <info>
          <name>Neonotso</name>
          <password>*******</password>
          <rank>admin</rank>
        </info>
        <story>
          <level>1</level>
          <enemy_power>1</enemy_power>
          <healthbar>1</healthbar>
          <pieces>0</pieces>
        </story>
        <stats>
          <movement>
            <speed>20</speed>
            <acceleration>225</acceleration>
            <deceleration>225</deceleration>
            <roll_anim>27<roll_anim>
            <roll_time>0</roll_time>
            <jump>-20</jump>
            <special_anim>15</special_anim>
            <special_value>90</special_value>
          </movement>
          <battle>
            <power>0</power>
            <defence>0</defence>
            <charge_time>0</charge_time>
            <energy_use>0</energy_use>
          </battle>
          <generic>
            <experience>0</experience>
            <level>1</level>
            <version>4</version>
            <type>energy</type>
          </generic>
        </stats>
        <inventory>
          <slot_1>8</slot>
          <slot_2>47</slot>
          <slot_3>12</slot>
          <slot_4>34</slot>
          <slot_5>59</slot>
          <slot_6>20</slot>
          <slot_7>83</slot>
        </inventory>
      </player>
    </profiles>
    The single root element is "profiles". I would like to know how to use EasyXML to get the various values and text from the document to MMF2.

    Thanks,

    Neonotso

  6. #6
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module

    Join Date
    Jul 2006
    Posts
    1,027
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I get the data off of an XML document?

    I'm pretty sure you would use the autoparse system... an example should have came with the extension.

    Check out this thread: http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=20033


    The file here: http://www.clickteam.com/epicenter/ubbthreads.php?ubb=download&Number=516

    Should answer your questions, I think ^^

    Also, may I ask why you are wanting to use XML?

  7. #7
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    England
    Posts
    3,546
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)

    Re: How do I get the data off of an XML document?

    If you are using XML you should at least use <slot id="5">59</slot> instead of <slot_5>59</slot>, or you might as well be using INI (which is easier).
    .:::.Joshtek.:::.

  8. #8
    No Products Registered

    Join Date
    Nov 2006
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I get the data off of an XML document?

    Hi all,

    Thanks! I think you are right that I should be using INI files instead of XML. I was trying XML because of an answer to a question I asked on this thread: here. Someone suggested I use INI, but someone else suggested XML, so I wasn't sure what to do. I'm much better at using INI, and truly I don't think that I'll be getting a massive amount of users on the game I'm making, so yes, I think INI would be better. If ever I endeavor to use XML, though, I'll most probably benefit from the info that has been provided.

    Thanks for all the help!

    Neonotso

  9. #9
    No Products Registered

    Join Date
    Jun 2006
    Location
    Texas
    Posts
    1,002
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I get the data off of an XML document?

    I actually don't think you should use the INI object for this at all.

    XML gives you greater freedom to group your data together, and as you are doing something a bit more complex then simple configuration settings I would recommend that you use XML.

    There are two ways to use the EasyXML object. There is the AutoParse system and then there is the manual way.

    For your case I would recommend using the manual way becuase you only want to load one player at a time more then likely.

    Start at the root element, get the first child of the element (Or get a child from an index). This will give you your first player element.

    At the player element getting the first child again will give you the Info element. Now you can get the first child and the next siblings to get the Name, Password, and Rank by using the Get Child Text expression.

    So here is the order so far:

    Root Element
    First Child
    Current Element: Player
    Get string attribute "id" (Store the id of the player).
    First Child
    Current Element: Info
    First Child
    Current Element: Name
    Get Child Text (Get the name of the player and store it)
    Next Sibling
    Current Element: Password
    Get Child Text (Get the password of the player and store it)
    Next Sibling
    Current Element: Rank
    Get Child Text (Get the rank of the player and store it)
    Parent
    Next Sibling
    Current Element: Story
    First Child
    Current Element: Level


    And repeat ^^.




  10. #10
    No Products Registered

    Join Date
    Nov 2006
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How do I get the data off of an XML document?

    Ahh... That makes sense. Cool, so now I can try out XML! Thanks very much! This sure is a great forum - I always get my questions answered!

Similar Threads

  1. Replies: 17
    Last Post: 10th July 2013, 01:46 PM
  2. Help To Open External Document
    By douglasdog in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 16th January 2009, 09:06 AM
  3. Failed to save document
    By Valurinn in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 3rd November 2006, 08:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •