Might as well write this down somewhere...
Traditional
CSS
XPath
The traditional methods are faster for simple selections only.
Traditional
PHP:
document.getElementById('wrap');
document.getElementsByTagName('div');
document.getElementsByClassName("fancy blue"); // *
/* class method does not work in IE8 or FF2 */
CSS
PHP:
document.querySelector('#wrap > h2 + div');
document.querySelectorAll('p.fancy');
/* Disregard; IE7 FF3 */
XPath
PHP:
document.evaluate("//div", document, null, 0, null);
function(){
var emu = new ActiveXObject("Msxml2.DOMDocument");
emu.async = false;
emu.resolveExternals = false;
}
emu.selectNodes('//p')
emu.selectSingleNode('//p')
/* Where emu is a emulated mirror document of the current HTML doc
have fun; http://msdn.microsoft.com/en-us/library/ms757828(v=VS.85).aspx */
The traditional methods are faster for simple selections only.