dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: xml file to object containg arrays etc

  1. #1
    Junior Member
    Join Date
    Jul 2002
    Location
    berlin
    Posts
    23

    xml file to object containg arrays etc

    Hi all,

    i've been stuck on this for hours now, and i really hate to go to bed with this bad feeling of unsolved problems in my stomach (4.45am over here), so any help is greatly appreciated.

    i tried to get my head around the data-components of flash mx pro, took a look at the xml class, but actually i only want _this_ to be done:


    i'm having an sql-database that is already converted in single xml-files (like user1.xml, user2.xml etc.), which (of course) contains nodes, attributes etc.

    to work with those files in flash i need them to be written into objects that contain the nodes etc. as arrays (some multi-dimensional) or something that lets me access them in actionscript using the "blah.bleh" or "blah[x]" syntax.

    example:
    [xml would be]
    <structure>
    <users>
    <element id="0" n_id="0" />
    <element id="1" n_id="1" />
    <element id="2" n_id="2" />
    <element id="3" n_id="3" />
    </users>
    </structure>

    [to address in actionscript as:]
    myCustomXMLObject.structure.users.element[i].id


    this can't be so hard to be done, i thought this would be a rather easy task using data-component-stuff, maybe this structure is already available fom the XMLConnector or the DataSet?

    I don't know, would be really nice if anybody had a quick and easy (or if has to be: a complicated) solution...


    thanks
    d

    //Edit: some mistyping
    Last edited by trixie stalker; 06-14-2004 at 10:48 PM.

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    It is not documented but flashs xml implementation automatically links to the ID tags. See this post:

    http://www.flashkit.com/board/showth...hreadid=297324

    Thanks

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

  3. #3
    Junior Member
    Join Date
    Jul 2002
    Location
    berlin
    Posts
    23
    hi luke,

    thank you for your answer, it was really fun to read the thread.


    but, what i was looking for is easier (i think) than flatten out the xml into an array (maybe my example with the ids was misleading):

    i need a way to keep my xml hierarchy and make it an actionscript-object:
    if this node contains attributes that are numbers make them an integer,
    if this node contains a string make it a string,
    if it is more complex (e.g. has children) make it an object,
    if this node appears twice+, make it an array etc...
    all of this recursively of course,
    and in the end you have a mirror of the xml as actionscript-object (i thought this would be exactly what the schema in the xmlconnector does)

    so maybe, is there simply a property inside a dataset, xmlconnector or xml(?) - object, that points to this specific object that contains an exact reproduction of my xml hierarchy?


    thanks again
    d

  4. #4
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    A few people have tried this sort of thing. I often hear people mention they are going to attempt these things and this is the last you ever hear of them (maybe there is a connection).

    I beleive some of the new Macromedia technologies do this is a 'sort of' way.

    Personally I would be inclined to learn the XML object and its percularities. One advantage is that the XML object is based on a reasonably 'standard' XML DOM implementation, so when you do XML DOM work in Java, .Net or whatever it will be familar to you (it won't be the same, just familar).

    Thanks

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

  5. #5
    Junior Member
    Join Date
    Jul 2002
    Location
    berlin
    Posts
    23
    hahaha, ok thank you.

    this sounds really bad,
    maybe i'll think about another way again...


    thanks for your help anyway


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