When the WXR version is >1.1, the first loop iteration will try with a non-existent wpns and item.find('%spost_type' % wpns) is None, hence .text will raise an exception.
item.find('%spost_type' % wpns)
The WXR that I exported has all types of items, hence it's more flexible to assign the post type, then filter for post and page types later.
Fixed Wordpress import when importing WXR files above version 1.1.
Also handle all-in-one WXR files by importing only pages and posts.
Looks good, thanks.