Hi there :-)
I have some problems with the same instance of my xmldocument across 3
different classes. See code below:
class one {
protected static XmlDocument doc = new XmlDocument();
public static XmlDocument getXmlDocument( ){
XmlDocument doc = new XmlDocument();
XmlDeclaration xmlDecl = doc.CreateXmlDe claration("1.0" ,
"iso-8859-1", null); //"iso-8859-1"
doc.InsertBefor e(xmlDecl, doc.DocumentEle ment);
return doc;
}
}
class two{
private static XmlDocument doc = one.getXmlDocum ent();
public static XmlElement getNewXmlElemen t(string elementName, string
stringValue)
{
XmlElement element = doc.getXmlDocum ent().CreateEle ment("",
elementName, null);
element.InnerTe xt = stringValue;
return element;
}
}
class test{
XmlDocument doc = one.getXmlDocum ent();
XmlElement e = two.getNewXmlEl ement("Referenc edOrder", "test");
doc.AppendChild (e);
doc.Save(Consol e.Out);
}
Error:
An unhandled exception of type 'System.Argumen tException' occurred in
system.xml.dll
Additional information: (translated from danish) The node to be inserted
comes from a different documentcontext
Does anyone know why ?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!