public static void AppendAllChildren(XmlNode source, XmlNode dest)
{
// Not sure, but the ToArray MIGHT be needed because AppendChild MIGHT remove the node from the source
// which MIGHT interfere with iterating over them.
foreach (var node in source.ChildNodes.Cast<XmlNode>().ToArray())
{
// It's nice if the independent HMTL file we are copying can have its own title, but we don't want to duplicate that into
// our page document, which already has its own.
if (node.Name == "title")
continue;
// It's no good copying file references; they may be useful for independent testing of the control source,
// but the relative paths won't work. Any needed scripts must be re-included.
if (node.Name == "script" && node.Attributes != null && node.Attributes["src"] != null)
continue;
if (node.Name == "link" && node.Attributes != null && node.Attributes["rel"] != null)
continue; // likewise stylesheets must be inserted
dest.AppendChild(dest.OwnerDocument.ImportNode(node,true));
}
}