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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:25:17+00:00 2026-05-21T22:25:17+00:00

How do I display distinct items in the autocomplete list? I don’t want the

  • 0

How do I display distinct items in the autocomplete list? I don’t want the duplicates to show up in the list. I’m reading the data from an XML file.

Here’s my web service code:

[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ScriptService]
     
    public class WebService : System.Web.Services.WebService
    {
        [WebMethod]
        public string[] GetItemsList(string prefixText, int count)
        {
            List<string> suggestions = new List<string>();
            using (XmlTextReader reader = new XmlTextReader(HttpContext.Current.Server.MapPath("flightdata3.xml")))
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "departurelocation")
                    {
                        string itemName = reader.ReadInnerXml();
                        if (itemName.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase))
                        {
                            suggestions.Add(itemName);
     
                            if (suggestions.Count == count) break;
                        }
                    }

                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "destinationlocation")
                    {
                        string itemName = reader.ReadInnerXml();
                        if (itemName.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase))
                        {
                            suggestions.Add(itemName);

                            if (suggestions.Count == count) break;
                        }
                    }

                }
            }
            return suggestions.ToArray();
        }
    }
  • 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-21T22:25:17+00:00Added an answer on May 21, 2026 at 10:25 pm

    To guarantee a count you would have to check for distinct items before adding them:

    if(!suggestions.Contains(itemName))
      suggestions.Add(itemName);
    

    Otherwise you end up worst case with only one suggestion.

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

Sidebar

Related Questions

My issue is that I want to display data in a hierarchal structure as
I need to select distinct rows from Textfile display below. TextFile 123| one| two|
I display data into an html table, w/ a drop down box with a
I display set of images(small). I need to show the larger image(300*300) at some
I would like to display details of an xml error log to a user
How would one display any add content from a dynamic aspx page? Currently I
What I like to achieve is a: display all Items that are in all
) I am making a SQL query to display a high score list of
In a continuous subform, I display records based on a DISTINCT query. Because it's
This is my base query select distinct a.projects , case when(billing_fy!=0) then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) from

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.