A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Generic XML reader

  1. #1
    Junior Member
    Join Date
    Aug 2000
    Posts
    27

    Generic XML reader

    Howdy!

    So every Flash tutorial/help file I've found so far has been for reading an XML file which has been written for a specific purpose.

    In other words, they're all designed for their specific XML files, and assume that all nodes will be called "state," and all states will have the same set of attributes, etc.

    Like a human can read
    Code:
    <people lastupdate="9/14/2005" dir="">
        <person name="John" bgcolor="78A615" photo="john.jpg">
            <bgswf url="admire_hhbg.swf" />
    	<desc>BLAB!</desc>
        </person>
    </people>
    and know how it's structured... or
    Code:
    <state sname="California">
    	<city>San Francisco</city>
    </state>
    or
    Code:
    <Slides>
      <slideNode jpegURL="image001.jpg">caption100</slideNode>
      <slideNode jpegURL="image002.jpg">caption150</slideNode>
      <slideNode jpegURL="image003.jpg">caption200</slideNode>
    </Slides>
    ... is it possible to create a generic reader that reads structure and just dumps data into an array, or do they all have to be desgined specifically? Do records have to be searched for by name, ie) "person", or can you tell Flash to read "if the name of the main node is person, do this"?

  2. #2
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    It does not matter how you name the node (however, attributes for a given node are refrenced by name). What is important is the structure of how the nodes are nested withing one another. So in that sense, yes you could have a generic reader for a given node structure.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  3. #3
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    There are/was a couple of XML to Object translators which would create an object structure for you.

    At the end of the day the XML structure in Flash is an Array, and it isn't to hard to use once you get used to it. You will find this especially useful if you ever have to work with XML in another language as if you use a dom parse you will get objects with childNodes, parentNode, etc.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center