// doesn't use insertNode, because we don't foster these; and will always have a stack. private void InsertNode(Node node) { // if the stack hasn't been set up yet, elements (doctype, comments) go into the doc if (stack.Count == 0) { doc.AppendChild(node); } else { if (IsFosterInserts()) { InsertInFosterParent(node); } else { CurrentElement().AppendChild(node); } } // connect form controls to their form element if (node is Element && ((Element)node).Tag.IsFormListed) { if (formElement != null) { formElement.AddElement((Element)node); } } }