open 1201438.xml ; register-namespace xh http://www.w3.org/1999/xhtml ; my $first = 1 ; for //xh:div[@class='data'] { if not($first) echo :n ', ' ; $first = 0; echo :s :n @id '=' xsh:subst(., '\W', '', 'g') ; } echo ;