gt: 		for(int i=index;i<nodes.length;i++) {
context: /**
   * Copyright (c) 2014, the Railo Company Ltd.
   * Copyright (c) 2015, Lucee Assosication Switzerland
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either 
   * version 2.1 of the License, or (at your option) any later version.
   * 
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   * 
   * You should have received a copy of the GNU Lesser General Public 
   * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
   * 
   */
  package lucee.runtime.text.xml;
  
  import java.util.ArrayList;
  import java.util.Comparator;
  import java.util.Iterator;
  import java.util.Map.Entry;
  
  import lucee.runtime.PageContext;
  import lucee.runtime.dump.DumpData;
  import lucee.runtime.dump.DumpProperties;
  import lucee.runtime.dump.DumpTable;
  import lucee.runtime.dump.DumpUtil;
  import lucee.runtime.dump.SimpleDumpData;
  import lucee.runtime.exp.ExpressionException;
  import lucee.runtime.exp.PageException;
  import lucee.runtime.exp.PageRuntimeException;
  import lucee.runtime.op.Caster;
  import lucee.runtime.text.xml.struct.XMLObject;
  import lucee.runtime.text.xml.struct.XMLStruct;
  import lucee.runtime.type.Collection;
  import lucee.runtime.type.KeyImpl;
  import lucee.runtime.type.dt.DateTime;
  import lucee.runtime.type.it.EntryIterator;
  import lucee.runtime.type.it.KeyIterator;
  import lucee.runtime.type.it.StringIterator;
  import lucee.runtime.type.util.ArraySupport;
  import lucee.runtime.util.ArrayIterator;
  
  import org.w3c.dom.Document;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  /**
   * 
   */
  public final class XMLNodeList extends ArraySupport implements NodeList, XMLObject{
  
  	private boolean caseSensitive;
  	private Document doc;
  	private Node parent;
  	private String filter;
  	private final short type;
  	
  	/**
  	 * @param parent Parent Node
  	 * @param caseSensitive
  	 */
      public XMLNodeList(Node parent, boolean caseSensitive, short type) {
      	this(parent,caseSensitive,type,null);
      }
      public XMLNodeList(Node parent, boolean caseSensitive,short type, String filter) {
          this.filter=filter;
          this.type=type;
          if(parent instanceof XMLStruct) {
              XMLStruct xmlNode = ((XMLStruct)parent);
              this.parent=xmlNode.toNode();
              this.caseSensitive=xmlNode.getCaseSensitive();
          }
          else {
              this.parent=parent;
              this.caseSensitive=caseSensitive;
          }
          this.doc=this.parent.getOwnerDocument();
      }
  
  	@Override
  	public int getLength() {
  		return XMLUtil.childNodesLength(parent,type,caseSensitive,filter);
  	}
  
  	@Override
  	public Node item(int index) {
  		return XMLCaster.toXMLStruct(getChildNode(index),caseSensitive);
  	}
  
  	@Override
  	public int size() {
  		return getLength();
  	}
  
  	@Override
  	public Collection.Key[] keys() {
  		Collection.Key[] keys=new Collection.Key[getLength()];
  		for(int i=1;i<=keys.length;i++) {
  			keys[i-1]=KeyImpl.init(i+"");
  		}
  		return keys;
  	}
  	
  	@Override
  	public int[] intKeys() {
  		int[] keys=new int[getLength()];
  		for(int i=1;i<=keys.length;i++) {
  			keys[i-1]=i;
  		}
  		return keys;
  	}
  	
  	@Override
  	public Object removeEL(Collection.Key key) {
  		return removeEL(Caster.toIntValue(key.getString(),-1));
  	}
  
  
  	@Override
  	public Object remove(Collection.Key key) throws PageException {
  		return removeE(Caster.toIntValue(key.getString()));
  	}
  
  	@Override
  	public Object removeEL(int index) {
  		int len=size();
  		if(index<1 || index>len) return null;
  		try {
  			return XMLCaster.toXMLStruct(parent.removeChild(XMLCaster.toRawNode(item(index-1))),caseSensitive);
  		} 
  		catch (Exception e) {
  			return null;
  		}
  	}
  	
  	@Override
  	public Object removeE(int index) throws PageException {
  		int len=size();
  		if(index<1 || index>len)
  			throw new ExpressionException("can't remove value form XML Node List at index "+index+
  			        ", valid indexes goes from 1 to "+len);
  		return XMLCaster.toXMLStruct(parent.removeChild(XMLCaster.toRawNode(item(index-1))),caseSensitive);
  	}
  
  	@Override
  	public void clear() {
  		Node[] nodes=getChildNodesAsArray();
  		for(int i=0;i<nodes.length;i++) {
  			parent.removeChild(XMLCaster.toRawNode(nodes[i]));
  		}
  	}
  
  
  	@Override
  	public Object get(String key) throws ExpressionException {
  		return getE(Caster.toIntValue(key));
  	}
  
  	@Override
  	public Object get(Collection.Key key) throws ExpressionException {
  		return get(key.getString());
  	}
  	
  	@Override
  	public Object getE(int key) throws ExpressionException {
  		Object rtn= item(key-1);
  		if(rtn==null) throw new ExpressionException("invalid index ["+key+"] for XML Node List , indexes goes from [0-"+size()+"]");
  		return rtn;
  	}
  
  	@Override
  	public Object get(String key, Object defaultValue) {
  		int index=Caster.toIntValue(key,Integer.MIN_VALUE);
  		if(index==Integer.MIN_VALUE) return defaultValue;
  	    return get(index,defaultValue);
  	}
  
  	@Override
  	public Object get(Collection.Key key, Object defaultValue) {
  		return get(key.getString(),defaultValue);
  	}
  
  	@Override
  	public Object get(int key, Object defaultValue) {
  		Object rtn= item(key-1);
  		if(rtn==null) return defaultValue;
  		return rtn;
  	}
  
  	@Override
  	public Object set(String key, Object value) throws PageException {
  		return setE(Caster.toIntValue(key),value);
  	}
  
  	@Override
  	public Object set(Collection.Key key, Object value) throws PageException {
  		return set(key.getString(), value);
  	}
  	
  	@Override
  	public Object setE(int index, Object value) throws PageException {
  		// check min Index
  			if(index<1)
  				throw new ExpressionException("invalid index ["+index+"] to set a child node, valid indexes start at 1");
  		
  		Node[] nodes=getChildNodesAsArray();
  		
  		// if index Greater len append
  		if(index>nodes.length) return append(value);
  		
  		// remove all children
  		clear();
  		
  		// set all children before new Element
  		for(int i=1;i<index;i++) {
  			append(nodes[i-1]);
  		}
  		
  		// set new Element
  		append(XMLCaster.toNode(doc,value,true));
  		
  		// set all after new Element
  