element1: parent.contents()[myIdx + (moveLeftRange ? -1 : 0)],
             element2: parent.contents()[myIdx + childrenLength-1 + (moveRightRange ? 1 : 0)]
         };
-    }
+    },
 
+    toXML: function() {
+        var wrapper = $('<div>');
+        wrapper.append(this._$);
+        return wrapper.html();
+    }
 });
 
 var TextNode = function(nativeNode, document) {
 
     createTextNode: function(nativeNode) {
         return new this.TextNodeFactory(nativeNode, this);
+    },
+
+    toXML: function() {
+        return this.root.toXML();
     }
 });
 
 
 
     });
 
+    describe('Serializing document to WLXML', function() {
+        it('keeps document intact when no changes have been made', function() {
+            var xmlIn = '<section>Alice<div>has</div>a <span class="uri" meta-uri="http://cat.com">cat</span>!</section>',
+                doc = getDocumentFromXML(xmlIn),
+                xmlOut = doc.toXML();
+
+            var parser = new DOMParser(),
+                input = parser.parseFromString(xmlIn, 'application/xml').childNodes[0],
+                output = parser.parseFromString(xmlOut, 'application/xml').childNodes[0];
+            
+            expect(input.isEqualNode(output)).to.be.true;
+        });
+    });
+
 });
 
 });
\ No newline at end of file