A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Extending the XML Object

Hybrid View

  1. #1
    Amidst the concern about lacking support for methods in the XML object outside of what is natively available in Flash 5 (Core DOM I think), I was wondering if anyone has worked on creating an extended set of methods that would include things like getElementsByName(), getAttributes(), or others.

    I've been working on writing a getElementsByName() method but haven't quite hooked it up to the XML object yet... so far, it just acts as a function.

    I'm also NOT a seasoned XML veteran by any means, so even if I did get one written, I don't know that it would be the correct implementation, per se.

  2. #2

    Recursion and XML Object

    Looking into writing a getElementsByName() method for XML trees, I realized that it would have to be added to the prototype of the ELEMENT class for XML within ActionScript and not just the XML class.

    Internally, if I am correct, Flash should be handling elements and data for XML trees separately from the the top-level XML object that is exposed in the documentation of the language.

    Is there any information that anyone might have about how to get at the classes of nodes, elements, etc. in ActionScript -- or information that might set me along a straighter path? I may be completely wrong on most of this.

  3. #3
    Senior Moderator
    Join Date
    Apr 2000
    Location
    Sheffield, UK
    Posts
    3,881
    There are two objects in flash 5 that control xml, there is obviously the XML object which controls the input/output and parsing of xml data and then there is the undocumented XMLnode object which describes XMLnodes. So you can extend this object and your function will work for all xmlnodes:

    Code:
    XMLnode.prototype.yourfunction=function(args){
        //your code
    }
    and you can call it using for example:

    Code:
    myxml.firstChild.yourfunction()

  4. #4

    XMLNode and properties

    Thanks.

    I was looking at this object tonight. I literally stumbled onto it because I figured it had to be there. Using a couple of "typeof" statements followed by keywords like "Element", "XMLElement", "Node", and "XMLNode", I finally came across the one that was listed as a function. I also tested a lot of others thinking that there might be a more robust structure going on behind the scenes.

    Here is what I came up with for properties of XML vs. XMLNode (granted, these are empty -- no XML loaded):


    XML type is function
    Property : status has the value 0
    Property : docTypeDecl has the value
    Property : xmlDecl has the value
    Property : nodeValue has the value null
    Property : nodeName has the value null
    Property : attributes has the value [object Object]
    Property : childNodes has the value
    Property : lastChild has the value null
    Property : firstChild has the value null
    Property : parentNode has the value null
    Property : previousSibling has the value null
    Property : nextSibling has the value null
    Property : nodeType has the value 1

    XMLNode type is function
    Property : nodeValue has the value
    Property : nodeName has the value null
    Property : attributes has the value [object Object]
    Property : childNodes has the value
    Property : lastChild has the value null
    Property : firstChild has the value null
    Property : parentNode has the value null
    Property : previousSibling has the value null
    Property : nextSibling has the value null
    Property : nodeType has the value


    So XMLNode handles everything else? I couldn't find any other similar objects (Attr, Element, CharacterData, Text, etc.).

    How do you come up with this object? Did someone from Macromedia announce it, or did you also just stumble on it? I couldn't find anything on the Internet describing this object.


  5. #5
    Senior Moderator
    Join Date
    Apr 2000
    Location
    Sheffield, UK
    Posts
    3,881
    As i said before this object is *undocumented* meaning that there isnt any official text on the subject from macromedia, it was Branden Hall who let it leak!

  6. #6

    Undocumented

    Originally posted by FlashGuru
    As i said before this object is *undocumented* meaning that there isnt any official text on the subject from macromedia, it was Branden Hall who let it leak!
    Is there any resource you know of that provides "unofficial" information about undocumented structures built into ActionScript? Or, do you have a list of items that you know of and would be willing to share?

    Thanks --

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