The XMLNode.AppendChild function in Xojo doesn't work well, if the new child is not part of the same xml tree as the old one. So if you need to copy from one XMLDocument to another, you need to copy the subtree. The function below does the copying and works well in one client project:
Sub AppendChildCopy(extends parent as XmlNode, other as XmlNode) // parent document for creating new objects dim doc as XmlDocument = parent.OwnerDocument dim neu as XmlNode // create matching type of node in new document if other isa XmlTextNode then neu = doc.CreateTextNode(other.Value) elseif other isa XmlComment then neu = doc.CreateComment(other.Value) else neu = doc.CreateElement(other.Name) end if // now copy all attributes dim u as integer = other.AttributeCount-1 for i as integer = 0 to u dim a as XmlAttribute = other.GetAttributeNode(i) neu.SetAttribute(a.Name, a.Value) next // copy all children dim c as XmlNode = other.FirstChild while c <> nil neu.AppendChildCopy c c = c.NextSibling wend // and store new child parent.AppendChild neu End SubUseful? Comments? Problems? Your feedback is welcome!