             newNode.nodeName = XObjUtils.encodeElementTag(qname, newNode);
             return newNode;
         }
+        else if (recurse)
+        {
+            if (obj is IXObjReference)
+            {
+                // don't recurse refs
+                return internal_encodeValue(obj, qname, parentNode, false);
+            }
+            else
+                return internal_encodeValue(obj, qname, parentNode);
+        }
         else
-            return internal_encodeValue(obj, qname, parentNode);
-    }
-    
-    protected function internal_encodeValue(obj:Object, qname:XObjQName, parentNode:XMLNode):XMLNode
+        {
+            // else skip it - likely an XObjRef from earlier
+            return null;
+        }
+    }
+    
+    protected function internal_encodeValue(obj:Object, qname:XObjQName, parentNode:XMLNode, recurse:Boolean=true):XMLNode
     {
         var myElement:XMLNode;
         

                    continue;
                
                var propQName:XObjQName = new XObjQName("", fieldName);
                encodeValue(obj[fieldName], propQName, myElement);
            }
        }
        else if (typeType == XObjXMLEncoder.ARRAY_TYPE)

        return xmlDocument;
    }

    public function encodeValue(obj:Object, q:*, parentNode:XMLNode, recurse:Boolean=true):XMLNode
    {
        var qname:XObjQName = new XObjQName();;
        
