I'm am using the HttpWebRequest.GetResponse() to get an XML file from a client.
The client XML is returned with everything decoded.
The client is returning the Envelope.
The client is returning part of the data inside a [CDATA wrapper. It returns several required elements, then it returns a [CDATA with the remaining elements.
I want to deserialize the data eventually.
If I try to write to an XMLDocument it errors:
XmlDocument xmlResults = new XmlDocument();
xmlResults.XmlResolver = null;
xmlResults.LoadXml(soapResponseMsg);
I have tried stripping out the Envelope.
Decoding the < and > back to < and >.
But when I deserialize the raw data, it doesn't find the values between the [CDATA so it doesn't deserialize anything within that.
Then I tried stripping out the CDATA, but then it errors, because the client has data within the elements with < and > symbols, so then I get an error:
>Data at the root level is invalid. Line 1, position 1."
<class>GVWR<26001</class>
So it thinks the < symbol above is a command!
I have tried all kinds of encoding tricks.
request.ContentType = "text/xml;charset=\"utf-8\""; // add escaped
request.Accept = "text/xml";
and
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encode))
... hoping there is some setting that will retrieve the XML data with the < > as they should be, but leave the body < as it should.
Is there something?
Thanks!