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 hasSimpleContent?
How do I use the method hasSimpleContent?

Apr 15th, 2005 05:55
Martin Honnen,


The method hasSimpleContent takes no argument and returns true if the
XMLList is empty or contains exactly one XML element object which has
simple content or contains no elements at all. Otherwise false is returned.
Here are some examples:
  var emptyList = new XMLList();
  alert(emptyList.hasSimpleContent()); // shows 'true'
  // one element which has simple content
  var godList = <>
    <god>Kibo</god>
  </>;
  alert(godList.hasSimpleContent()); // shows 'true'
  // one element which has complex content
  var godList = <>
    <god>
      <name>Kibo</name>
    </god>
  </>;
  alert(godList.hasSimpleContent()); // shows 'false'
  // list containing more than one element
  var godList = <>
    <god>Kibo</god>
    <god>Xibo</god>
  </>;
  alert(godList.hasSimpleContent()); // shows 'false'