1 Reply Latest reply on Aug 8, 2006 10:28 PM by Newsgroup_User

    remove duplicate entry in list component

    Rain1522
      I have a list component which loads xml into it. I have multiple entries in the list that are the same and i want to remove the duplicates. if anyone has an idea or hint it would be appreciated.

      Thanks
        • 1. Re: remove duplicate entry in list component
          Level 7

          "Rain1522" <webforumsuser@macromedia.com> wrote in message
          news:ebamrt$s5h$1@forums.macromedia.com...
          >I have a list component which loads xml into it. I have multiple entries in
          >the
          > list that are the same and i want to remove the duplicates. if anyone has
          > an
          > idea or hint it would be appreciated.
          >
          > Thanks
          >
          > function loadGulf(){
          > import mx.xpath.XPathAPI;
          > var cityXml:XML = new XML();
          > cityXml.ignoreWhite = true;
          > cityXml.onLoad = function(success:Boolean) {
          > trace("onload...");
          > if (success) {
          > trace("success...");
          > // Retrieve all Cities notes within /document/City.
          > var thePath_str:String = "/document/City"; // path of nodes
          > var plan_array:Array = XPathAPI.selectNodeList(this.firstChild,
          > thePath_str);
          > for (var i:Number = 0; i < plan_array.length; i++) {
          > var planArray = plan_array .firstChild.nodeValue;
          >
          > function checkMatch(compare:String) {
          > for(j=0;j<myList.length;j++){
          > if (myList.getItemAt(j).label==compare){
          > return true;
          > }
          > }
          > }
          > if(checkMatch(plan_array
          .firstChild.nodeValue)!=true){
          > myList.addItem(plan_array .firstChild.nodeValue);
          > }
          >
          > }
          > } else {
          > trace("error loading XML");
          > }
          > };
          > cityXml.load("new.xml");
          > }
          > loadGulf();
          >

          I have a book with a function for quick searching arrays, but it is at work.
          If not answered by tomorrow morning then I will try to remember to post a
          solution.