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 1 people (100%) answered Yes
Recently 1 of 1 people (100%) answered Yes

Entry

How do I use the method attributes?
How do I use the method attributes?

Apr 9th, 2005 02:52
Martin Honnen,


The method attributes takes no argument and returns an XMLList with the
attributes of this XML object which are in no namespace. It does not
return all attributes however as attributes in a namespace are ignored,
see the discussion in
http://groups-beta.google.com/group/netscape.public.mozilla.jseng/browse_frm/thread/962ec04a6833c3ef/60848956fe1e81d1#60848956fe1e81d1
[Note: Attributes of an XML object representing an XML element can be
accessed like normal object properties with a special attribute property
identifier wildcard
  xmlObject.@*
  xmlObject['@*']
so while there is a method attributes to access attributes you might not
need/use the method but prefer the shorter property access instead. See
  http://www.faqts.com/knowledge_base/view.phtml/aid/35118/fid/1762
for further details.]
Here is an  example of using the method attributes:
  var paragraph = <p id="p1" xml:lang="en" class="style1">Kibology for
all.</p>;
  alert(paragraph.attributes().length()); 
  // shows 2 as the xml:lang attribute is in a namespace
  // use @*::* if you want all attributes e.g.
  alert(paragraph.@*::*.length()); // shows 3