W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2003

Re: DOM getElementsByAttribute

From: Joseph Kesselman <keshlam@us.ibm.com>
Date: Mon, 24 Mar 2003 17:42:07 -0500
To: www-dom@w3.org
Message-ID: <OF25FAAB1C.1D87CF62-ON85256CF3.007A441D-85256CF3.007CB597@us.ibm.com>

getElementsByAttribute[Value] has been considered in the past, but never 
survived into the spec since there appeared to be adequate (and less 
argumentative) alternatives:

In DOM Level 1: Write a tree-walker that searches for those attributes. 
There are many existing tree-walkers you can borrow code from.

In DOM Level 2, if Traversal is supported: Implement a NodeFilter which 
tests for the presence/value of the attribute and plug that into a 
TreeWalker or NodeIterator. Or prescan the document, build a lookup table, 
and implement your own retrieval method using that. Or, if you can't 
depend on Traversal but can validate the document against a DTD, use 
Document's getElementByID method.

In DOM Level 3, if the XPath module is supported: Write a suitable XPath 
and evaluate that.


______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more. 
"may'ron DaroQbe'chugh vaj bIrIQbej"  ("Put down the squeezebox and nobody 
gets hurt.")
Received on Monday, 24 March 2003 17:42:18 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:56 GMT