473,385 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Reading and updating an xml file

38
Hi I havw an XML file in my windows application which is used to store some
project details. I want to read some node value from this file and then update one value of another node. Can anybody help me to do this...?

XML file looks like this:

[HTML]
<AFPDetails>

<Printer>
<AFPPrinter>IBM AFP 240</AFPPrinter> 'want to read this IBM AFP240 value
</Printer>

<FileName>
<NextNumber>0</NextNumber> want to update 0 to 1,2...
</FileName>
</AFPDetails>


[/HTML]


I am using a code like this :
Expand|Select|Wrap|Line Numbers
  1.         Dim xmlDocumnetObject As XmlDataDocument = New XmlDataDocument
  2.         Dim xmlNodeObject As XmlNode
  3.   xmlDocumnetObject.Load("AFPDetails.xml")
  4.  
  5. ' to read value . This work fine
  6. xmlNodeObject = xmlDocumnetObject.SelectSingleNode("//Printer/AFPPrinter")
  7.  
  8.         If Not xmlNodeObject Is Nothing Then
  9.  
  10.             AFPDriver = xmlNodeObject.InnerText
  11.  
  12.         End If
  13.  
  14.  
  15. 'write value .This has not updated in the xml file but no exception thrown
  16.  
  17.  
  18. xmlNodeObject = xmlDocumnetObject.SelectSingleNode("//FileName/NextNumber")
  19.             If xmlNodeObject IsNot Nothing Then
  20.                 xmlNodeObject.InnerText = (fileNextNumber + 1).ToString
  21.  
  22.                 xmlDocumnetObject.Save("AFPDetails.xml")
  23.             End If
  24.  
  25.  
thanks in advance
jaleel
Oct 12 '07 #1
2 1094
jaleel
38
finally I got the problem and solved. In xmlDocumnetObject.Save("AFPDetails.xml") statement , we need to specify the correct path.

Thanks
Oct 15 '07 #2
Shashi Sadasivan
1,435 Expert 1GB
Thanks for sharing the solution.

Weekneds can make wonderful things happen, isint it

cheers
Oct 15 '07 #3

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

Similar topics

14
by: deko | last post by:
Do I need to use flock() when reading a file into an array? It's possible that the file in question could be open at the time the file('filename') request is made. I realize flock() is required...
0
by: David Alliet | last post by:
Hello, I'm having a bit of a problem with ASP and Excel. A client has developed his own program, which calculates alot of financial stuff, in excel. I'm doing his websites and he has requested...
1
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the...
1
by: Sunil Pathi | last post by:
Thanks in Advance I have a XML file which is read from a .aspx page. I need to read through all the elements, find the values of them and pass them on to the stored procedure which updates the...
4
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
16
by: Roy | last post by:
I use a Access 2K application.I am trying to use Chuck Grimsby(clsReadTextFile.txt)class utility to read a text file and then do a import of the same into my database.The question is how to call...
3
by: siaj | last post by:
Hi.. I m just trying to learn using XML file as a datastore. I am reading a dataset from a XML file and then trying to update the XML file with some changes in the dataset. My code is as...
6
by: muttu2244 | last post by:
hi all am updating the same file in ftp, through multiple clients, but am scared that two clients may open the same file at a time, and try updating, then the data updated by one data will be...
0
by: Rum | last post by:
Hi, I`m writing an application that can be updated from remote server. Application config file is updating too (adding new sections etc...) When application is updating i make a copy of old config...
16
by: WATYF | last post by:
Hi there... I have a huge text file that needs to be processed. At the moment, I'm loading it into memory in small chunks (x amount of lines) and processing it that way. I'd like the process to be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.