Elements may exist without being on the page itself. Just upload the HTML into a dummy div.
var wrapper = document.createElement('div');
wrapper.innerHTML = "<ul><li>foo</li><li>bar</li></ul>";
wrapper.getElementsByTagName('li').length;
Given your changes, we are faced with a sticky situation, as you want getElementById. The case would probably be easy if you could just create a new virtual document through document.implementation.createDocument, but IE does not support this at all.
- , , - <body><input value="</body>" /></body>? , , </body>, , . , , , - Sizzle, , jQuery, . , , - , - ?
var response_el = document.createElement('html'), foo;
response_el.innerHTML = the_html_elements_content;
foo = Sizzle('#foo', response_el);