faqts : Computers : Programming : Languages : JavaScript : XML : E4X (ECMAScript for XML) : XMLList objects

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

How do I use the method children?
How do I use the method children?

Apr 14th, 2005 04:39
Martin Honnen,


The method children of XMLList objects takes no argument and calls the
method children
(http://www.faqts.com/knowledge_base/view.phtml/aid/35371/fid/1784) of
each XML object in this XMLList and returns an XMLList with the children
of all XML objects in the XMLList it is called on.
A wild card property access with '*' has the same result:
  var godList = <>
    <god>
      <name>Kibo</name>
      <home>http://www.kibo.com/</home>
    </god>
    <god>
      <name>Xibo</name>
    </god>
  </>;
  alert(godList.children().length()); // shows 3
  alert(godList.children()); 
  /* shows
  '<name>Kibo</name>
   <home>http://www.kibo.com/</home>
   <name>Xibo</name>'
  */
  // compare to (shorter) wild card property access
  alert(godList.*.length()); // shows 3
  alert(godList.* == godList.children()); // shows 'true'