If the XML data is retrieved serialized as BLOB and the value is a document node, it is returned in its original encoding. If an application wants to insert the document and get it back in the same encoding (round-tripping), it can insert and retrieve documents as BLOBs. In this case, there is no guarantee that the documents will be lexically identical; however, they will be equal in the sense that their canonical representations will be identical.
If the value is a query result, it is returned encoded in UTF-8.