The node to be inserted is from a different document context

Posted by BDotA on Stack Overflow See other posts from Stack Overflow or by BDotA
Published on 2010-06-10T22:57:46Z Indexed on 2010/06/10 23:03 UTC
Read the original article Hit count: 283

Filed under:
|

When I am Calling AppendChild, I get this error: The node to be inserted is from a different document context."

static public XmlNode XMLNewChildNode(XmlNode oParent, string sName, string sNamespaceURI, string sNodeType)
{
    XmlNode oNode = moDoc.CreateNode(sNodeType, sName, sNamespaceURI);
    oParent.AppendChild(oNode);
    return oNode;
}

this is a code that is converted from its VB 6.0 version which was this: please ignore the optional parametes, I have overloads for them in C# version:

Public Function XMLNewChildNode(ByVal oParent As IXMLDOMNode, ByVal sName As String, Optional ByVal sNamespaceURI As String = "", Optional ByVal sNodeType As String = "element") As IXMLDOMNode
'**************** DESCRIPTION *******************
  'Create a new Child Node for passed Parent.
'***************** VARIABLES ********************
  Dim oNode As IXMLDOMNode
'************************************************
  Set oNode = moDoc.createNode(sNodeType, sName, sNamespaceURI)
  Call oParent.appendChild(oNode)
  Set XMLNewChildNode = oNode
End Function

so anything is different in VB 6.0 and C# for working with XMLs?

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml