Hi Josh, are your data ordered? (e.g. MAP_ID is the first <li>, SITE_ADDRESS the second, ...)
If yes you can use a index based approach (from 4.8ms to 0.9ms on IE). var $foo = $(foo); var data = $foo.find(".atr-value"); var parcelOutput = 'Parcel ID: ' + $(data[0]).text() + '<br>' + 'Address: ' + $(data[1]).text(); Otherwise you can build a hash table of your name - value attributes and du a hash lookup (from 4.8ms to 2.7ms on IE) var $foo = $(foo); var names = $foo.find(".atr-name"); var data = $foo.find(".atr-value"); var hash = {}; for (var j=0; j<names.length; j++) { hash[$(names[j]).text()] = $(data[j]).text(); } var parcelOutput = 'Parcel ID: ' + hash['MAP_ID'] + '<br>' + 'Address: ' + hash['SITE_ADDRESS']; see my examples on the profiling test page: http://jsbin.com/ifico/edit by(e) Stephan 2009/2/18 Josh Rosenthal <maric...@gmail.com>: > So... a question regarding selector efficiency. > The following snippet of HTML describes attributes associated with a polygon > in an KML. Its basically a table of data, contained as <span>s in <li>s in > a <ul>. Given this snippet, what would be the best (fastest) way to return > the values of MAP_ID and SITE_ADDRESS > foo = "<h4>GISDATA.ASSESSPARNC_POLY_PUBLIC</h4> > > <ul class="textattributes"> > <li><strong><span class="atr-name">MAP_ID</span>:</strong> <span > class="atr-value">16-27</span></li> > <li><strong><span class="atr-name">SITE_ADDRESS</span>:</strong> <span > class="atr-value">396 Main St</span></li> > <li><strong><span class="atr-name">SITE_OTHER_FIELD</span>:</strong> <span > class="atr-value">Grat Data</span></li> > <li><strong><span class="atr-name">USE_CODE</span>:</strong> <span > class="atr-value">101</span></li> > <li><strong><span class="atr-name">TOWN_ID</span>:</strong> <span > class="atr-value">116</span></li> > <li><strong><span class="atr-name">WARREN_GROUP_05_MAP_ID</span>:</strong> > <span class="atr-value">M:0016 B:0000 L:0027</span></li> > <li><strong><span class="atr-name">ACRES</span>:</strong> <span > class="atr-value">0.67102373655</span></li> > > </ul>" > > The following works > parcelOutput = 'Parcel ID: ' + > jQuery(foo).find('li:contains("MAP_")').not('li:contains("WARREN_GROUP")').children('.atr-value').text() > + '<br>' + 'Address: ' + > jQuery(foo).find('li:contains("SITE_ADDRESS")').children('.atr-value').text(); > Is there a better/more efficient way to return these values? > Thanks!