Handle case when namespace is used and defined in same element

This XML was failing, but is valid:

```xml
<ns:Element xmlns:ns="myNs"/>
```

@ajlai please take a look.