Im working on an application where i need to fetch data and im using a js function to do the same

My xml is this http://pastebin.com/sUd3Z7QK

and the js function for fetching data is as follows

Code:
else if(requestType == relatedProductsRequest){       
ArrayForRelatedProductsDetails =[];
var related_product_ids=[];
console.log("inside relatedProductsRequest::::::::");   

for(i = 0 ; i < successData.length; i++) {           
    var r_product_id = successData[i].getElementsByTagName("Product_id")[0].childNodes[0].nodeValue;
    for(i=0;i<successData.length;i++)
    {          related_product_ids.push(successData[i].getElementsByTagName("Related_product_id")[i]);
             }
    related_product_ids=related_product_ids.filter(function(n){
        return n != undefined
    });          
    for(i=0;i<related_product_ids.length;i++) {   
                   if(productSelected == r_product_id){                
            ArrayForRelatedProductsDetails.push(related_product_ids[i].innerHTML);   
                        }}
    fetchData(relatedProductInfoRequest);
    requestType = NoContentDisplayRequest;
}
}
here Here sucessData is the array containing the entire xml (using xmlDoc.getElementsByTagName(root))

http://i.stack.imgur.com/ARr9b.png

the first for loop will loop till the length of the sucessdata array(i.e xml size) with the 2nd for loop im getting all the related product ids and storing them in an array

http://i.stack.imgur.com/dwsUt.png

and with the 3rd loop im iterating matching the selected product id with the product id's in the xml and on match im storing the related prodict ids and proceeding

now my issue is this code doesnt proceed ahead of the first root node in the xml i.e doesnt go beyond the first product id 1001310101

now previously when i was using this xml structure

http://pastebin.com/qDNz28m4

i had this js code which gave the proper output

else if(requestType == relatedProductsRequest){
//console.log("inside relatedProductsRequest::::::::");
ArrayForRelatedProductsDetails =[];
for(i = 0 ; i < successData.length; i++) {
var r_product_id = successData[i].getElementsByTagName("Product_Id")[0].childNodes[0].nodeValue;
var related_product_id = successData[i].getElementsByTagName("Related_product_id")[0].childNodes[0].nodeValue;

if(productSelected == r_product_id){
ArrayForRelatedProductsDetails.push(related_product_id);
}
}
fetchData(relatedProductInfoRequest);
requestType = NoContentDisplayRequest
}
so what am i doing wrong in my js? or is my xml structure wrong?
i hope ive put my question across properly thanks in advance