G
Guest
I have an example below that is not working correctly.
I have a web application that passes a System.Xml.XmlDocument object
"oInputDoc" around to functions byval.
I do not want the "oInputDoc" object to change when it is passed into
"myFunction".
I want to use the data in the object, modify it "myFunction" and then pass
it out as an "oOutputDoc".
On the way back out of the function, the "oInputDoc" is being changed by
..net, not sure why it is changing, as it is set to byval as it is passed into
"myFunction"
see example below,which is a scaled down version of what is happening to me.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string s = "<root><name>Keep this Data here</name></root>";
XmlDocument oInputDoc = new XmlDocument();
XmlDocument oOutputDoc = new XmlDocument();
oInputDoc.LoadXml(s);
oOutputDoc = myFunction(oInputDoc);
Response.Write(oInputDoc.OuterXml);
Response.Write("<BR>");
Response.Write(oOutputDoc.OuterXml);
}
private XmlDocument myFunction(System.Xml.XmlDocument oInputDoc)
{
string s = "<root><name>New Output Data</name></root>";
oInputDoc.LoadXml(s);
return oInputDoc;
}
any help is greatly appreciated.
Thanks,
Bob
I have a web application that passes a System.Xml.XmlDocument object
"oInputDoc" around to functions byval.
I do not want the "oInputDoc" object to change when it is passed into
"myFunction".
I want to use the data in the object, modify it "myFunction" and then pass
it out as an "oOutputDoc".
On the way back out of the function, the "oInputDoc" is being changed by
..net, not sure why it is changing, as it is set to byval as it is passed into
"myFunction"
see example below,which is a scaled down version of what is happening to me.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string s = "<root><name>Keep this Data here</name></root>";
XmlDocument oInputDoc = new XmlDocument();
XmlDocument oOutputDoc = new XmlDocument();
oInputDoc.LoadXml(s);
oOutputDoc = myFunction(oInputDoc);
Response.Write(oInputDoc.OuterXml);
Response.Write("<BR>");
Response.Write(oOutputDoc.OuterXml);
}
private XmlDocument myFunction(System.Xml.XmlDocument oInputDoc)
{
string s = "<root><name>New Output Data</name></root>";
oInputDoc.LoadXml(s);
return oInputDoc;
}
any help is greatly appreciated.
Thanks,
Bob