/// <summary> /// Used by Content Export to recursively add children /// </summary> /// <param name="originalDescendants"></param> /// <param name="currentChildren"></param> /// <param name="currentXml"></param> private void AddChildXml(IContent[] originalDescendants, IEnumerable<IContent> currentChildren, XElement currentXml) { foreach (var child in currentChildren) { //add the child's xml var childXml = Export(child); currentXml.Add(childXml); //copy local (out of closure) var c = child; //get this item's children var children = originalDescendants.Where(x => x.ParentId == c.Id); //recurse and add it's children to the child xml element AddChildXml(originalDescendants, children, childXml); } }