I have javascript code that reads from an xml that contains a category node and populates a dropdown list with it. That category node is created every time the user creates a new product listing. However, this means that when the xml is read, the category is filled with items such as Camera, Camera, Camera, Others. How do I remove that or is there a distinct option?
function loadXMLcat()
{
var xmlhttp=false;
 if (window.XMLHttpRequest)
{
  xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","auction.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 
var category;
var str;
var i;
var j;
str=("<p>Category : <select onchange=\"reveal(this)\" name=category>");
var x=xmlDoc.getElementsByTagName("Product");
if(x.length>0)
{
    for (i=0;i<x.length;i++)
    {
        category=xmlDoc.getElementsByTagName("Category");
        str+="<option value=" + category[i].childNodes[0].nodeValue + ">" + category[i].childNodes[0].nodeValue + "</option>"
        /**var arr = category;
        var sorted_arr = arr.sort()
        var results = [];
        for (var i = 0; i < arr.length - 1; i++) 
        {
            if (sorted_arr[i + 1] !== sorted_arr[i]) 
            {
                str+="<option value=" + arr[i] + ">" + arr[i] + "</option>"
                str+="<option value=" + sorted_arr[i] + ">" + sorted_arr[i] + "</option>"
            }
        }**/
    }
    str+="<option id=\"others\" value=\"Other\">Other</option>";
}
else
str+="<option id=\"others\" value=\"Other\">Other</option>";
str+=("</select></p>");
document.getElementById('category').innerHTML=str;
}
 
    