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 7985807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:39:56+00:00 2026-06-04T11:39:56+00:00

How can i search the geonames using their API and get city name and

  • 0

How can i search the geonames using their API and get city name and coordinates?
Link to their API

  • 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-06-04T11:39:57+00:00Added an answer on June 4, 2026 at 11:39 am

    Of course it depends entirely on the actual search you want to perform. Let’s say you want to find all locations in Great Britain that start with Lon. The URL that will perform this search (as an example, much may change for a real search) is:

    http://api.geonames.org/search?name_startsWith=lon&country=GB&maxRows=10&username=demo
    

    You can pop that in your browser and see the results:

    <geonames style="MEDIUM">
    <totalResultsCount>334</totalResultsCount>
    <geoname>
        <toponymName>London</toponymName>
        <name>London</name>
        <lat>51.50853</lat>
        <lng>-0.12574</lng>
        <geonameId>2643743</geonameId>
        <countryCode>GB</countryCode>
        <countryName>United Kingdom</countryName>
        <fcl>P</fcl>
        <fcode>PPLC</fcode>
    </geoname>
    <geoname>
        <toponymName>Lone</toponymName>
        <name>Lone</name>
        <lat>58.33333</lat>
        <lng>-4.88333</lng>
        <geonameId>2643732</geonameId>
        <countryCode>GB</countryCode>
        <countryName>United Kingdom</countryName>
        <fcl>P</fcl>
        <fcode>PPL</fcode>
    </geoname>
    <!-- and so on ... -->
    </geonames>
    

    Note that you want the lat and lng elements under each geoname. With LINQ to XML (include System.Linq and System.Linq.Xml in your namespace declarations):

    var xml = XElement.Load("http://api.geonames.org/search?name_startsWith=lon&country=GB&maxRows=10&username=demo");
    
    var locations = xml.Descendants("geoname").Select(g => new { 
                        Name = g.Element("name").Value, 
                        Lat = g.Element("lat").Value, 
                        Long = g.Element("lng").Value
                    });
    
    foreach (var location in locations)
    {
        Console.WriteLine("{0}: {1}, {2}", location.Name, location.Lat, location.Long);
    }
    

    Of course you may choose to use these values differently, and you may want to parse Lat and Long into doubles.

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

Sidebar

Related Questions

I know we can search posted reviews on Yelp using Yelp Review Search API.
Let's say I have a form where users can search for people whose name
I'm using a MySQL database. I have a products database where users can search
Currently users can search a database using php and ajax with the results shown
I can search a CJK char (such as 小 ) by using a unicode
On my search.php page, where users can search things by city/location, the search is
I have one search box where users can search for either the movie name
Can search engines such as Google index JavaScript generated web pages? When you right
All the examples that I can search online use the App.Config mode of specifying
I'm writing a library search engine where a user can search based on various

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.