473,799 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLdocument value changing automatically.

7 New Member
I had this strange problem in handling XMLDocuments in asp.net.Though the problem occurs while working on the main application.I will try to explain it with shorter code.
I had a form with 2 buttons.The first button loads a file and second button make some changed in extracted XML node.The strange thing is that I am not touching the XMLdocument created in second button but still its getting changed.It will be more clear by seeing the examples.
The code behind for first button is :
protected void Button1_Click(o bject sender, EventArgs e)
{
XmlDocument xdcSettings = new XmlDocument();
string fileName = System.Configur ation.Configura tionSettings.Ap pSettings.Get(" RequestFilePath ") + "Settings.x ml";
xdcSettings.Loa d(fileName);
Session["Settings"] = xdcSettings;
Session["CurrentSetting "]=xdcSettings.Se lectSingleNode( "Settings/Setting[@id='S1']"); }

And for second button is :
protected void Button2_Click(o bject sender, EventArgs e)
{
XmlDocument xdcSettings = (XmlDocument)Se ssion["Settings"];
xdcSettings.Sav e(@"C:\Document s and Settings\gaurav .RC\Desktop\Set tingsBefore.xml ");
XmlNode xdc = (XmlNode)Sessio n["CurrentSetting "];
xdc["Elements"].InnerText = "101,102,10 3";
xdcSettings.Sav e(@"C:\Document s and Settings\gaurav .RC\Desktop\Set tingsAfter.xml" );
}

I am not able to understand how the variable xdcSettings in second button code is getting changed without me doing anything.The sample Settings.xml file is given as:
<Settings>
<Setting id="S1">
<Elements>101,1 02,103</Elements>
</Setting>
<Setting id="S2">
<Elements>5,6,7 ,8</Elements>
</Setting>
</Settings>
Is it because everything is being passed as reference and hance getting changed.Neverth eless still I am not sure how a standalone variable gets changed?
Nov 20 '07 #1
0 1004

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1143
by: Andrea N. | last post by:
I'm new to .NET XML classes, so here my dilemma I really like the XMLDataDocument concept of synchronizing automatically XMLDocument and DataSet with a common schema. Can I automatically syncronize 2 XMLDocument with Synchronization Trasformation Schema in the middle? Here my plan I'm going to write an application which the core data model is based on XMLDataDocument with my own schema. The application frontend will edit the...
13
23037
by: Matthew Wieder | last post by:
In my C# application, I have class which has method that opens an XML document, modifies it and saves it out. I run that method for several different XML documents. What I've found is that the Load emthod on the MXLDocument isntance loads the document into memory (as it should) but I have no way of releaseing that memory throughout the application, and I run out of memory. The documents I'm loading are abou 10 MB in size, and I run out...
5
5788
by: Ben R. | last post by:
Hi, Could someone explain the functional difference between these classes? From what I understand, xpathdocument is faster in some scenarios, but I'm not sure why. Further, why is it that the method of getting xml data into these two classes differs? (xmldocument uses the load method, whereas xpathdocument doesn't have this available and one must specify the path to the xml data in the constructor, or so it seems). Any help would be...
4
2461
by: David Thielen | last post by:
Hi; I have nodes in the XmlDocument I create that need to be written exactly as is - not converting < to %lt; and no changing the whitespace. (This is for the SpreadsheetML schema and it reads the <Data> nodes literally.) How can I do this? -- thanks - dave
4
4183
by: David Grogan | last post by:
Hi, 2 questions.... 1. I'm parsing an XHTML document that contains both the default namespace (xmlns="http://www.w3.org/1999/xhtml") and a custom one (xmlns:r="...") - both of these being attributes of <html>. When I then insert new XmlNodes into the DOM the HTML tags all end up getting an unnecesarry 'xmlns' attribute added, elements with the 'r' prefix don't, which is correct. Is there any way to stop the XmlNode/XmlWriter from...
1
1613
by: David | last post by:
I need to find a good online resource which teaches the use of the XmlDocument framework in more depth than is covered in MS's online doc. I need to create a multi-level XML document like the one listed below. Using XmlDocument, I can create the <books> and the individual <name> and <price> elements, but I am unsure how to create the <category> and <title> elements and close them after creating the detail elements. Eg. how can I go 2+...
5
1609
by: Bob P | last post by:
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...
1
3630
by: Joe Monnin | last post by:
I have a web service that takes an XmlDocument as a parameter, performs some processing on it, and saves it to a database. The web service signature looks similar to this: public void SaveDocument(XmlDocument doc) { //Method logic omitted } The web service worked great in .net 1.1, but upon upgrading to .net 2.0 IIS
3
27063
by: Andy Fish | last post by:
Hi, I am creating a new XmlDocument from scratch, but I can't see how I can make a namespace declaration and associate a prefix with it. For instance in the following example: XmlDocument doc = new XmlDocument(); XmlElement el = doc.CreateElement("foo:data"); doc.AppendChild(el); doc.Save("foo.xml");
0
9689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7573
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.