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