Hi Gaya,
You can use the Eval(eval(...)) trick to iterate xpath functions but there is no xpath function for copying values from a secondary data source, so you have to use some code. Since we get asked this question a lot, we created qRules back in 2007 to address the common coding questions that we get asked a lot. qRules can do a filtered copy from a repeating table in a secondary data source to the main data source or vice versa.
To use qRules you will need InfoPath 2007 or 2010. If you are doing browser-based forms in 2007, you will need to admin deploy them, which is not too hard but does complicate publishing. SharePoint 2010 gets around this with sandboxes.
If you're interested, we can arrange to have someone call you and show you a sample of how to go about doing what you have described with qRules. If you can attach a sample XSN with instructions (just type into InfoPath view the instructions of what you want to happen), I will inject qRules and show you the technique over the weekend.
Let us know.