e.Source will get you the current node -- the one the button is in. So, you can modify:
thisXDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:A_PlaylistData/@APD_FilenameAndPath").text = sFilename;
to:
e.Source.selectSingleNode("@APD_FilenameAndPath").text = sFilename;
If, for example, A_PlaylistData is your repeating group.