in reply to Template Toolkit's FOREACH

First off, it helps if you actually post code that works as-is (the __END__ marker with the *DATA filehandle is very handy for this). Or, in this case, doesn't work, but is at least in a state that can show what you mean...

Next, that's pretty messy. Why are you looping through and then checking for only one particular value? Without testing, I think you mean:

<!-- you only use 'foo', so why loop and check for it? --> <tr><td>foo</td>[% data.main.ResultSet.Listing.foo %]</tr> [% FOREACH l IN data.main.ResultSet.Listing %] <tr><td>test 3</td>[% l.url.content %]</tr> [% END %]
There's only one place in your sample where you're not only looping, but you're using all the values you loop over. The rest seem to be hard-coded...