A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: accessing XML node with a dynamic path variable

  1. #1

    accessing XML node with a dynamic path variable

    I'm loading an XML file into flash, and as I parse through the XML, I'm saving the path's to the XML nodes for later reference and updating, but I'm having a problem when I try to access dynamically.

    Here's a super simplified example of what isn't working for me. If I can resolve this, I think I can take it from there.

    I CAN access an attribute in a node if I hard code the path like this
    Code:
    trace (_root.myXML.childNodes[0].childNodes[1].attributes["width"])
    but I want to access the attribute value using a variable name as the path. Here's what I tried (which didn't work).

    Code:
    NodePath = "_root.myXML.childNodes[0].childNodes[1]"                    
    trace (eval(NodePath).attributes["width"])
    - DancingPaul
    www.dancingpaul.com

  2. #2
    to put it another way, this works:
    Code:
    trace (_root.myXML.childNodes[0].childNodes[1].attributes["width"]
    but this doesn't:
    Code:
    NodePath = "_root.myXML.childNodes[0].childNodes[1].attributes[\"width\"]"  
                      
    trace (NodePath)
    // or
    trace (eval(NodePath))
    Any help with this would be greatly appreciated.
    - DancingPaul
    www.dancingpaul.com

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