@XML_TOOLS Version "2.0" @CUSTOM_CODE function contains(fullStringOrArray, subString){ return fullStringOrArray.indexOf(subString)!=-1; } function removeFromArray(_array, _value){ _array.splice(_array.indexOf(_value), 1); } var myBuilder = new JSXMLBuilder(); myBuilder.load($xmlData); var elements = myBuilder.elements[0]; var particles = elements.childElement("Animation").childElement("Particles"); // Check if any of the existing particles contains a head bone for (var i=0; (particles.childElement(i)); i++){ // the condition is to check if the child element exists (!= undefined) var currElement=particles.childElement(i); if(currElement.childElement("Bone").text=="Head"){ if(currElement.childElement("Name").text=="glass_break"){ return; // not necessary to add } else{ // gather all the necessary info var int_start=currElement.childElement("Start").text; var int_end=currElement.childElement("End").text; // Insert the new glass particle (for when he touches glass with head myBuilder.addElementAt("Particle","", ""+int_start+"\ "+int_end+"\ Head\ glass_break",particles.index+1,particles.level+1); break; } } } $xmlData=myBuilder.generateXML(); // update the global variable with the new XML