Fixed potential segfault
Added support for foo[1] and foo[@attr='value'] XPath queries