A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Nodes named <text> in E4X

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Location
    London
    Posts
    12

    Nodes named <text> in E4X

    HI all,

    I must admit I'm not enjoying getting my head around E4X. The latest issue is I can't access any nodes in my tree which have the tag name "text":

    Code:
    <root>
        <section>
            <text>Hello</text>
        </section>
    </root>
    This doesn't work...

    code:
    root..text



    ...I'm guessing because ActionScript thinks I am trying to say "root..text()".

    This works...

    code:
    root.section['text']



    ...but it means I need to know the path first which defeats the purpose of E4X!

    Does anyone know a way round this, or do I need to change my tag names to something else?

    Cheers,
    Dave
    Last edited by daveystew; 06-15-2009 at 03:49 PM.

  2. #2
    Junior Member
    Join Date
    Jun 2009
    Location
    London
    Posts
    12
    OK, I got it. Slightly convoluted, but I guess I'm still learning the power of this new syntax:

    code:
    var list:XMLList = xml..*.elements('text');


  3. #3
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Hi and welcome,

    As i understand it, E4X is a new extension to JavaScript that adds direct support for XML to JavaScript.
    (with limited browser support)

    a typical example is -

    Code:
    var x = new XML();
    
    x=
    <note>
    <from>Jani</from>
    <body>Don't forget me</body>
    </note>;
    For the example above, the JavaScript statement: document.write(x.from)
    will produce the output: Jani


    I posted the above before seeing your reply.
    Glad you're sorted

  4. #4
    Junior Member
    Join Date
    Jun 2009
    Location
    London
    Posts
    12
    Thanks for the welcome MD. Yup, I found some rather good links and am slowly getting my head round it!


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