for(var i = children.length - 1; i >= 0; i--) {
             childParts = children[i].toXML(level + 1);
-            
+            if(typeof childParts === 'string')
+                childParts = [document.createTextNode(childParts)];
+
             if(containsPrefixAndSuffix(i) && children[i] instanceof DocumentTextElement) {
                 $(node.contents()[0]).after(childParts);
             } else {