Okay, I thought that this error came from XQuery. I did not notice before that XQuery can operate on invalid XML document.
A minor note: XQuery definitely requires well-formed XML as input, but the http:send-request() function generates two results: the first one represents the XML response element, the second one represents the actual result – which is the reason why you need to explicitly choose the second item via "[2]".