On 7/6/07, <b class="gmail_sendername">Sander</b> <<a href="mailto:html5@zoid.nl">html5@zoid.nl</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div bgcolor="#ffffff" text="#000000">
<font size="-1">Hello,<br>
<br>
I'm not sure if this has been proposed yet (can hardly believe it
hasn't). But I couldn't find it in the specs so I just give it a go
anyway.<br>
<br>
<br>
I'd like to see a getElementsByAttr method. It would be quite similar
as the getElementsByClassName method but with an extra argument:<br>
<br>
getElementsByAttr(attribute_name, value)<br>
<br>
For attributes that can have more than one value (either seperated by
spaces or commas) the value argument may be a space(/comma) seperated
string or an array, similar to getElementsByClassName. If value is not
defined of perhaps a wildcard ("*") the method should return all nodes
that have the particular attribute, no matter what its value is.<br>
<br>
The method overlaps with both getElementsByClassName,
getElementsByTagName and getElementById, as these filter on attribute
value as well, but it still adds extra opportunities.<br>
<br>
cheers,<br>
Sander<br>
</font>
</div>

</blockquote></div><br>I personally prefer the DOM 3 XPath evaluate() method, which is implemented at least by Mozilla on the document object. Not sure about other UAs.<br><br>However, AFAICR, XPath doesn't meet all use cases, such as space-separated token lists, like @class.
<br><br><a href="http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathEvaluator">http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathEvaluator</a><br><a href="http://developer.mozilla.org/en/docs/DOM:document.evaluate">
http://developer.mozilla.org/en/docs/DOM:document.evaluate</a><br><br>Since these APIs are spread out over various specifications, it's hard to guess what common browsers are going to support in the future.  It would be nice if HTML5 informatively notes these other APIs that may be supported (XMLHttpRequest also fits in this category)
<br><br>-- <br>Jon Barnett