473,804 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# updating xml element

chathura86
227 New Member
hi, i want to update a xml element.i used the following code

Expand|Select|Wrap|Line Numbers
  1. System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
  2. System.Xml.XmlNode xmlUpdateNode;
  3.  
  4. xmlDoc.Load("XML//App_Var_Data.xml");
  5. xmlUpdateNode = xmlDoc.SelectSingleNode("NAME");
  6. xmlUpdateNode.InnerText = "chathura";
  7. xmlDoc.Save("XML//App_Var_Data.xml");
  8.  
when i execute i get the following exception
Object reference not set to an instance of an object.

please help pme to solve this problem

chathura bamunusinghe
Dec 4 '07 #1
4 4820
mzmishra
390 Recognized Expert Contributor
The main cause for this type of error is
1. nOt declaring variable
2. Bad scope of the variable
3.Bad inits/constructs


Just check you ahve done all these correctly and also let us know which line is throwing the exception
Dec 4 '07 #2
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Hi,
Could you please provide which line throws that exception?
I would assume that the following line throws the exception

xmlUpdateNode.I nnerText = "chathura";

are you sure that the element NAME exists in the xml document (case sensitive)
If it does is it the root element?

if not, what you need to search online is navigating through an xml document (xpath is your friend here)
Dec 4 '07 #3
chathura86
227 New Member
Hi,
Could you please provide which line throws that exception?
I would assume that the following line throws the exception

xmlUpdateNode.I nnerText = "chathura";

are you sure that the element NAME exists in the xml document (case sensitive)
If it does is it the root element?

if not, what you need to search online is navigating through an xml document (xpath is your friend here)
Yes

xmlUpdateNode.I nnerText = "chathura";
throws the exception.

i checked. element NAME exists(in upper case)
so please explain about xpath im new to c#

thanks

chathura bamunusinghe
Dec 4 '07 #4
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Hi,
Use Online search for tutorials Please....
XPath Tutorial
Manipulate XML data with XPath and XmlDocument
Dec 4 '07 #5

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

Similar topics

5
1349
by: christopher.c.brewster | last post by:
A few years ago my department defined a DTD for a projected class of documents. Like the US Constitution, this DTD has details that are never actually used, so I want to clean it up. Is there any tool that looks at existing documents and compares with the DTD they use? Christopher Brewster
4
2028
by: Darrel | last post by:
I'm creating a table that contains multiple records pulled out of the database. I'm building the table myself and passing it to the page since the table needs to be fairly customized (ie, a datagrid isn't going to work). On this page, people can update a variet of records. On submit, I want to then go in and update all of the records. Normally, I'd make each form element include a runat: server and then declare it in my codebhind so I...
3
1526
by: Asaf | last post by:
Hi, I have a MSSQL 2005 test DB with two tables: Table "T1Customers": T1CustomersRowEnum (PK, int, Not Null) T1CustomersFullName (nvarchar(50) null) Table "T2Details":
13
5331
by: mfreeman | last post by:
The minimal code (VB.NET 2003) needed to show this problem is shown below. All I do is loop through the records in the table and update them without making any changes. Out of 600 records, about 40 of them throw Concurrency violation errors in the update, and my GetAllColErrs function provides no output. In comparing the rows that throw errors with those that do not, I could find no pattern. It is obviously a bogus error, as the...
2
2276
by: Rob Long | last post by:
Hi I have an HTML select element in my page and it's multiple property is disabled (one item at a time mode) but I still want to transfer all the items in the select to the server when the form is submitted. I'm using javascript to change the multiple property of the select element to true and then I'm looping through each option to change its selected property to true.
1
1491
by: explode | last post by:
My table has 5 columns: Broj iksice, Prezime, Ime, Broj indeksa, Broj pohadjanja. This is the code in the dataset designer VB made it by it self: Private Sub InitClass() Me.columnBroj_iksice = New System.Data.DataColumn("Broj iksice", GetType(Double), Nothing, System.Data.MappingType.Element) Me.columnBroj_iksice.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "Broj_iksice")...
10
2246
by: chimambo | last post by:
Hi All, I have a little problem. I am retrieving records from a table and I want to update the records using checkboxes. I am able to display the database record quite alright and I have created an array of checkboxes, but my update loop is not working. Here is my code: /*---------This retrieves the records -------------*/ if($row_md) { do{ echo "<tr><td text align='right'>";
9
4040
by: mevryck | last post by:
Greetings I have a huge Javascript with inclusion of external scripts and all. I got this by doing a XSLT . Now I have the contents in a Javascript variable, but I'm not able to update the element with the javascript contents. But when viewed as a seperate HTML file with the below contents I'm able to see the milonic menu http://www.milonic.com . <div>
3
1301
by: Evan | last post by:
Hello - My script use a DB file which is written by XML, and the user load this DB file (XML tree in memory), and then do some updating about this tree, such as delete element, generate new element or move element. The thing is, my script is a cmd based program (based on module "cmd"), and there are many users would use this script at same time, in a shell style prompt (module "cmd"), so I want to implement a
2
1127
by: Andy | last post by:
I want to dynamically update a list of elements shown as a checkbox list. A file is used to store the elements, and elements can be added and deleted from the list. The trouble is that the window is not properly updated after deleting/adding items. I use the Detach()/Destroy() to remove the sizer, and then I create a new and updated sizer again. Apparently, not in a correct way... #################File...
0
9715
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
9595
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
10353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
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
5536
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...
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.