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

  • SEARCH
  • Home
  • 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 7167631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:36:57+00:00 2026-05-28T14:36:57+00:00

I try to get some data from Google Geocoding API with C# and ASP.net.

  • 0

I try to get some data from Google Geocoding API with C# and ASP.net. But I have trouble with XML responce. I get valid XML and I can get evry element besides “address_component” element. (XML looks like this : http://maps.googleapis.com/…)

    /* data is a string with XML from Google server */            
    XDocument receivedXml = new XDocument();
    receivedXml = XDocument.Parse(data);
    XName address = XName.Get("address_component");

    var root = reciviedXml.Root;              //returns corect XElement
    XElement result = root.Element("result"); //returns corect XElement
    IEnumerable<XElement> components = result.Elements("address_component"); //returns empty collection

This is another way, I’have tried it to with the same result.

    var results = reciviedXml.Descendants("address_component");

And when I try to get some descendant of like:

    var types = receivedXml.Descendants("type");

It’s the empty collection to. But another elements in “result” tag (like the “location” tag)I can get successfully.

Thanks for any advice.

  • 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-28T14:36:58+00:00Added an answer on May 28, 2026 at 2:36 pm

    The following:

    var receivedXml = XDocument.Load("http://maps.googleapis.com/maps/api/geocode/xml?latlng=49.1962253,16.6071422&sensor=false");
    Console.WriteLine(receivedXml.Root.Element("result").Elements("address_component").Count());
    Console.WriteLine(receivedXml.Descendants("address_component").Count());
    

    Writes 10 and 28 respectively. Make sure you are using the same instance – in your question you usereceivedXml as well as reciviedXml so you may have two instances XDocument and one of these may contain different data. Also you don’t need to instantiate XDocument as XDocument.Parse() will do it for you (and the address variable seems to be unused)

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

Sidebar

Related Questions

i'm working on google analytics and try to get some data from analytics. What
i try to get some Data from a Access Database via OleDB in a
I'm trying to parse some JSON data from the Google AJAX Search API. I
I've been using this code to try and get data from the google weather
I'm, trying to download some Google Analytics data from their API. I can download
I write a custom dialog and try to get some data from its parent
I'm trying to receive some data from a client in a server using Google
I have some problem to get the Google Analytics to work. I have got
I am trying to download some JSON from the google book API. The URL
I am trying to get some data from the user and send it to

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.