//div[@id="something" and not(@class="aa")]/img
did you try not operator of xpath . This will find all div tag with a specific id but not the specified class
So if you want img which doesn't have div as ancestor then :
//img[not(ancestor::div)]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…