diff --git a/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLList.java b/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLList.java
index <HASH>..<HASH> 100644
--- a/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLList.java
+++ b/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLList.java
@@ -250,6 +250,9 @@ class XMLList extends XMLObjectImpl implements Function {
                 //    There may well be a better way to do this
                 //    TODO    Find a way to refactor this whole method and simplify it
                 xmlValue = item(index);
+                if (xmlValue == null) {
+                    xmlValue = item(0).copy();
+                }
                 ((XML)xmlValue).setChildren(value);
             }
         }
Fix  Bug <I> -  Setting the value of an uninitialized child of an E4X object by using square bracket syntax causes Null Pointer Exception