Below is the code to do it in VTD-XML
import com.ximpleware.*;
public class queryAttr{
public static void main(String[] s) throws VTDException{
VTDGen vg= new VTDGen();
if (!vg.parseFile("input.xml", false))
return false;
VTDNav vn = vg.getNav();
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("//xml/ep/source/@type");
int i=0;
while((i = ap.evalXPath())!=-1){
system.out.println(" attr val ===>"+ vn.toString(i+1));
}
}
}