tags:

views:

18

answers:

1

If I want to create:

<foo>
  <bar>example1</bar>
  <bar>example2</bar>
</foo>

using e4x, and I already have:

foo.bar = <bar>example1</bar>

How do I add the additional bar tag?

+2  A: 

You either write another literal,

foo += <bar>example3</bar> ;

or you use the relevant methods: http://www.ibm.com/developerworks/library/x-javascript4x.html (Table-1),

var addition = <bar>example3</bar>
foo.insertChildAfter(foo.bar[1],addition) ;

HTH

FK82