Jump to content

load xml using jquery - getting duplicate items


brock82

Recommended Posts

I'm trying to load an xml file into an html file using jquery... i'm using jquery bc the site is built in Adobe's Business Catalyst and doesnt allow for any server-side scripting languages.

 

The XML fIle is broken down into five sections - Corporation Builder Subdivision Plan and Spec- with child nodes within themThe following node names are in the following format (Parent Child). The data that I am trying to display are the: "Builder BrandName", "Spec SpecStreet1", "Spec SpecPrice", "Subdivision SubParentName", "Plan Description", "Spec SpecElevationImage", "Spec SpecBedrooms", "Spec SpecBaths", "Spec SpecSqft", "Spec SpecGarage"So far I've managed to .find and .append all the information in the correct format within its appropriate div with one exception - The data is being repeated around 78 times. Where there should only be one version of each address. So my question is:What can i do to continue displaying the data on my page (http://www.fallsatimperialoaks.com/home-inventory/index_copy.html) without having the data repeated?The XML File is located at http://www.fallsatimperialoaks.com/I8959.xml

<script type="text/javascript">    $(document).ready(function(){        $.ajax({            type:"GET",            url:"/I8959.xml",            dataType:"xml",            success: function(data){        $('#load').fadeOut();                       $(data).find("Builder").each(function(){                                    var Brandname = $(this).find("BrandName").text();                var Subdivision = $(this).find("Subdivision SubParentName").text();                              $(data).find("Plan").each(function(){                                           var Description = $(this).find("Description").text();                              $(data).find("Spec").each(function(){                                var Address = $(this).find("Spec SpecStreet1").text();                var Price = $(this).find("Spec SpecPrice").text();                var Image = $(this).find("Spec SpecElevationImage").text() + '" width="220" height="124" alt="' + $(this).find("Spec SpecStreet1").text();                             var Beds = $(this).find("Spec SpecBedrooms").text();                var Baths = $(this).find("Spec SpecBaths").text();                var Sqft = $(this).find("Spec SpecSqft").text();                var Garage = $(this).find("Spec SpecGarage").text();//Append to homecontainer                             $("#homecontainer").append(' <div class="address"> ' + Address + ' <br><span>Section: ' + Subdivision + '</span>' + '</div>' + ' <div class="price"> $' + Price + ' <br><span> ' + Brandname + ' </span>' + '</div>'  + '<div class="clearboth"></div>' +  ' <div class="home-image"><img src="' + Image + '"/>' +'</div>' + ' <div class="home-description"> ' + Description + '</div>' +  '<div class="clearboth"></div>');            $("#homecontainer").append(' <div class="stats"><div class="beds"><img alt="" src="/images/ico-beds.png" style="border: 0px; width:22px;" /> ' + Beds + ' Bedroom(s)</div><div class="baths"><img alt="" src="/images/ico-baths.png" style="border: 0px; width:22px;" /> ' + Baths + ' Bath(s)</div><div class="sqft"><img alt="" src="/images/ico-sqft.png" style="border: 0px; width:22px;" /> ' + Sqft + ' Sq. Ft.</div><div class="garage"><img alt="" src="/images/ico-garage.png" style="border: 0px; width:22px;" /> ' + Garage + ' Car Garage</div></div>');                                        }); //End Data Function "Spec"                      }); //End Data Function "Plan"                    }); //End Data Function "Builder"                },            error:function(){            $("#homecontainer").text('Failed to get feed');        }    });});                   </script>

Any help is appreciated! 

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...