Use non-greedy regex to detect XML encoding

Fixes issue with stack overflow in regexp matcher (#8).