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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:17:17+00:00 2026-06-12T10:17:17+00:00

I am retrieving some results from an XML file and on the autosuggest I

  • 0

I am retrieving some results from an XML file and on the autosuggest I am trying to add some html code as such:

London, <br/>
United Kingdom

My code is this:

$.ajax({
                url: "veh.xml",
                dataType: "xml",
                success: function( xmlResponse ) {
                    var data = $( "geoname", xmlResponse ).map(function() {
                        return {
                            value: $( "reg", this ).text() 
                                   + '<br/>'
                                   + $( "model", this ).text()
                        };
                    }).get();
                    $( "#mainsearch" ).autocomplete({
                        source: data,
                        minLength: 0,
                        select: function( event, ui ) {
                            log( ui.item ?
                                "Selected: " + ui.item.value + ", geonameId: " + ui.item.id :
                                "Nothing selected, input was " + this.value );
                        }
                    });
                }
            });

and I get this result instead:

London,<br/>United Kingdom

I am trying to create a list effect.

My xml looks like this:

<geoname>
    <model>London</model>
    <reg>United Kingdom</reg>
    </geoname>


<geoname>
    <model>Paris</model>
    <reg>France</reg>
    </geoname>
  • 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-12T10:17:17+00:00Added an answer on June 12, 2026 at 10:17 am

    You get this result :

    London,<br/>United Kingdom
    

    Because the default render use by the autocomplete was an li element and the data was just put in as text, not as html.

    So, to change the render, you have to override the default render item and to add data in you item.

    $.ajax({
        url: "veh.xml",
        dataType: "xml",
        success: function( xmlResponse ) {
    
            var data = $( "geoname", xmlResponse ).map(function() {
                return {
                    value: $( "reg", this ).text() + '-' + $( "model", this ).text(),
                    reg: $( "reg", this ).text(),
                    model: $( "model", this ).text()
                };}).get();
    
            $( "#mainsearch" ).autocomplete({
                source: data,
                minLength: 0,
            focus: function( event, ui ) {
                $( "#mainsearch" ).val( ui.item.label );
                return false;
            },
                select: function( event, ui ) {
                    log( ui.item ?
                         "Selected: " + ui.item.value + ", geonameId: " + ui.item.id :
                         "Nothing selected, input was " + this.value );
                }
            }).data( "autocomplete" )._renderItem = function( ul, item ) {
                return $( "<li class='ui-menu-item' role='menuitem'></li>" )
                       .data( "item.autocomplete", item )
                       .append( "<a>" + item.reg + "<br />" + item.model +"</a>")
                       .appendTo( ul );
            };
        }
    });
    

    You have an example on the jQuery-UI Autocomplete presentation, with “custom data and display” : http://jqueryui.com/demos/autocomplete/#custom-data

    Browse source of the demo and you’ll find an other example.

    Hope my answer could help you to solve part of your problem.

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

Sidebar

Related Questions

I was retrieving some date records from my database with the following results: Date
I am retrieving some similar XML from the Yahoo API - <ResultSet version=1.0> <Error>0</Error>
I am retrieving birthdays from FQL and am getting some results back. My problem
Can anybody help me with retrieving some elements from the following example text: sdfaasdflj
Currently, I'm retrieving some data from a MySQL database table, but the problem is
For some reason I'm having a problem retrieving data from my database. It leaves
i am creating a few divs from some JSONP data that i am retrieving
I am building an application using Action script 3 I am retrieving some XML
I have a query in a stored procedure retrieving some data in XML format
I'm retrieving some records from a database using user = Users.all in the console

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.