> var $items = $('<items><item>Hello</item><item>world</item>...
jQuery will try to parse that with the browser's HTML parser, but it's not HTML. I don't know if that will cause you sorrow or not. http://groups.google.com/group/jquery-en/browse_thread/thread/95718c9aab2c7483/af37adcb54b816c3 As for getting the index, maybe something like this? $items.find('#my_item').prevAll().length