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

Apr 14th, 2005 03:38
Martin Honnen,


The method attributes takes no argument. It calls the method attributes
(http://www.faqts.com/knowledge_base/view.phtml/aid/35364/fid/1784) of
each object in this XMLList and returns an XMLList with the results in
order.
As the method attribute of XML objects does not return all attributes
but only those in no namespace the method attributes of XMLList objects
consequently does not return all attributes either but only those in no
namespace.
Here are some examples:
  var xmlList = <>
    <god name="Kibo" home="http://www.kibo.com/" />
    <god name="Xibo" />    
  </>;
  alert(xmlList.attributes().length()); // shows 3
  var xml = <gods>
    <god>
      <name>Kibo</name>
      <home xmlns:xlink="http://www.w3.org/1999/xlink"
            xlink:type="simple"
            xlink:href="http://www.kibo.com/">www.kibo.com</home>
    </god>
  </gods>;
  var xmlListOfDescendants = xml..*;
  // attributes in no namespace:
  alert(xmlListOfDescendants.attributes().length()); // shows 0 !