Error: “The node to be inserted is from a different document context”

Error: “The node to be inserted is from a different document context”

Asked on December 28, 2018 in XML.
Add Comment


  • 1 Answer(s)

    Before affixing it, import the node into the document:

    XmlNode oNode = moDoc.CreateNode(sNodeType, sName, sNamespaceURI);
     
    //necessary for crossing XmlDocument contexts
    XmlNode importNode = oParent.OwnerDocument.ImportNode(oNode, true);
     
    oParent.AppendChild(importNode);
    return oNode;
    

     

    Answered on December 28, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.