C# Stream Reader adding \n to XML

Posted by Terry on Stack Overflow See other posts from Stack Overflow or by Terry
Published on 2010-05-19T18:55:27Z Indexed on 2010/05/19 19:00 UTC
Read the original article Hit count: 436

Filed under:
|
|
|

I use the StreamReader class to obtain XML for my GeoCoding process from Google.

        StreamReader srGeoCode = new StreamReader(WebRequest.Create(Url).GetResponse().GetResponseStream());

    String GeoCodeXml = srGeoCode.ReadToEnd();

    XmlDocument XmlDoc = new XmlDocument();

    GeoCode oGeoCode = new GeoCode();

    XmlDoc.Load(GeoCodeXml);

I get XML back but it adds \n and other extras to the XML

<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<kml xmlns=\"http://earth.google.com/kml/2.0\"><Response>\n  <name>

I have the same code in VB and it does not do this. I can successfully GeoCode my information using the VB version of this console app.

Is there a reason the C# version adds this extra data to the XML that I retrieve back? I am trying my best to convert everything over to C#. I enjoy coding in it over VB.

© Stack Overflow or respective owner

Related posts about c#

Related posts about streamreader