javascript - E4X - Retrieve element without retrieving its children -


given xml object, how retrieve root element without retrieving children?

e.g.:

var examplexml = new xml("<parent name="teste"><child/><child2/><child3/></parent>"); examplexml.getonlyrootelement(); //<parent name="teste"/> 

i've found solution - flex e4x filter out children - didn't much. there better one?

ps: i'm running javascript in windows app using spidermonkey.

thanks

you can set child reference empty xmllist.

 examplexml.setchildren(new xmllist('')); 

if want preserve original xml object, make deep copy first

 childfreexml = examplexml.copy().setchildren(new xmllist('')); 

Comments