Richard Deeming is right — please see his comments to the question.
Yes, your XML file is valid. If you parsed it, it would perfectly parse.
But you are not parsing this file with your code. You are doing something which makes no sense at all. You call
LoadXml
not with this file. You try to parse just the line, which the string
str
calculated from
reply
, by removing some hard-coded strings.
This is not XML at all. No wonder, XML parser cannot parse some text which is not XML.
What to do? Parse the whole file first (in your case, from stream,
XmlDocument.Load Method (Stream) (System.Xml)), than change what you want.
You should never read lines from stream or file, to parse XML, unless you want to create your own parser, which hardly may make any practical sense.
—SA