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

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

1 of 2 people (50%) answered Yes
Recently 1 of 2 people (50%) answered Yes

Entry

How do I use the method length?
How do I use the method length?

Apr 11th, 2005 01:37
Martin Honnen,


While XML objects have a method length this always returns 1. This is
done to intentionally blur the distinction between an XML object and an
XMLList object containing exactly one value.
Here are some examples:
  var gods = <gods>
    <god>Kibo</god>
    <god>Xibo</god>
  </gods>;
  alert(gods.length()); // shows 1
  var xmlTextNode = new XML('Kibology for all.');
  alert(xmlTextNode.length()); // shows 1
  var attributeNode = <god name="Kibo" />.@name;
  alert(attributeNode.length()); // shows 1