Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 798291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:56:46+00:00 2026-05-14T22:56:46+00:00

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

  • 0

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.

Here is the VB Code:

    Dim wreqGeoCode As WebRequest = WebRequest.Create(strURL)
    Dim wresGeoCode As WebResponse = wreqGeoCode.GetResponse
    Dim srGeoCode As New StreamReader(wresGeoCode.GetResponseStream())
    Dim strXML As String = srGeoCode.ReadToEnd()
    Dim xmlDoc As New XmlDocument
    xmlDoc.LoadXml(strXML)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:56:47+00:00Added an answer on May 14, 2026 at 10:56 pm

    You need XmlDoc.LoadXml if you’re going to load a string. Load loads from a file.


    BTW, the alternative is also more efficient. You can load the document directly from the stream:

    WebRequest webRequest = WebRequest.Create(Url);
    using (WebResponse webResponse = webRequest.GetResponse())
    {
        using (Stream responseStream = webResponse.GetResponseStream())
        {
            XmlDocument XmlDoc = new XmlDocument();
            GeoCode oGeoCode = new GeoCode();
            XmlDoc.Load(responseStream);
        }
    }
    

    The using statements ensure that the WebResponse and Stream get cleaned up, even if an exception is thrown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need process concurent requests at my application. I use this code: public class
i want simultaneously read and write data into file. Can i use StreamReader and
in server -(multi)client application [TCP]. I use Socket, NetworkStream, StreamReader and StreamWriter for each
use C#,want to upload excel file on google doc. bellow syntax use to upload
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
I am trying use filehelpers class builder but I am kinda confused on what
StreamReader class has both close and dispose method. I want to know which method
I have defined a Pipe class in Java, making use of PipedReader and PipedWriter
I have rather class using TcpClient that spins of a Thread doing while (!streamReader.EndOfStream)
I have a class in my Silverlight app that (de-)serializes JSON strings to/from an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.