Re: DOM getElementsByAttribute

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 UTC