473,378 Members | 1,309 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,378 software developers and data experts.

How do I read and update an xmlfile without loading and saving?

Hi, I'll try to explain. I'm now using C# and I have an xmlfile that
contains users and information about them, this xmlfile can be read and
changed from many threads in my application, as many users can be connected
at the same time, the user information in the file can also be changed by
other programs, like an administration application. So my xmlfile needs to
be updated as soon as any application changes a value and it needs to
reflect in every other application at once, or at least as soon as a node
being read that has been changed.

I feel that I might not be explaining very good, I'll tell how it worked for
me in Delphi:

In Delphi there were a convenient wizard that mapped my xmlfile to objects,
so I easily could just access the xmldata by accessing the properties of my
generated class, if I change a value in a property of my class it was
instantly written to the xmlfile so that other applications could notice the
changes. And if I changed a value in the xmlfile and then read the value of
the property corresponding to the node I got the new value from the file.
Exactly what I needed.

In .NET and C# however I haven't been able to find something similar?

(Accessing the xmlfile by the serializing and data classes all seams to
require me to completely load and save the whole xmlfile each time a value
changes. I also haven't find any way to know if the data in the underlying
xmlfile has changed.)

(I haven't tried much yet thou, I've been reading up on the different xml
classes in MSDN and come to this conclusion without finding a solution).

Regards,
Lani
Nov 11 '05 #1
1 2346
Niklas Lagergren wrote:
In Delphi there were a convenient wizard that mapped my xmlfile to objects,
so I easily could just access the xmldata by accessing the properties of my
generated class, if I change a value in a property of my class it was
instantly written to the xmlfile so that other applications could notice the
changes. And if I changed a value in the xmlfile and then read the value of
the property corresponding to the node I got the new value from the file.
Exactly what I needed.

In .NET and C# however I haven't been able to find something similar?
Sure. Just have an object of a class, which maps to your xml (you can even
generate it from XML Schema using xsd.exe). Update object's properties and
serialize object to file. What you won't get is automatic serialization when a
property changes, but this can be implemented in a couple of minutes.
(Accessing the xmlfile by the serializing and data classes all seams to
require me to completely load and save the whole xmlfile each time a value
changes. What do you mean "accessing by the serializing"? Serialize() method serialize
object to a file, no need to read or parse existing file.
I also haven't find any way to know if the data in the underlying
xmlfile has changed.)

How do you do it in Delphi? Any magic tricks? Watch file's last-modified
attribute, this is the only way I'm aware of, this can be done a very elegant
and efficient way using FileSystemWatcher class - register a watcher and be
notified whenever something is changed in a file or directory.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: HolaGoogle | last post by:
hi all, can you please tell me what i should do to avoid session timeout when displaying my database info in my asp form (DisplayUserDatabase.asp)??? ** actualy it does load and display the...
3
by: Andrew Poulos | last post by:
If I do something like the following snippet in JS: xFile = "test.xml"; xDoc = document.implementation.createDocument("", "theXdoc", null); xDoc.load(xFile); // there's a pause here then ...
0
by: | last post by:
Use the method InsertAfter() from the XmlDocument class or AppendChild from XmlNode class. Here is a short example to use InsertAfter(). http://weblogs.asp.net/sonukapoor/articles/132854.aspx ...
0
by: Eric W | last post by:
Hi, I'm working on the .NET Compact Framework, and I need a way in which i store products in an xml file. Basically, when i add a product to the system, i want to either add it to the XML file,...
6
by: sghi | last post by:
Hi All, I'm new to this group and quite new to access/vba. So, shortly after beginning to write a simple application for my wife, I came across a blocking problem: I need to intercept the sql...
6
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data)...
4
by: Highlander | last post by:
Hello all. The following lines are an excerpt from a machine.config file: <configuration> <system.net> <connectionManagement> <add address="*" maxconnection="10"/> </connectionManagement>...
12
by: Sean Davis | last post by:
I am working on a simple script to read from one database (oracle) and write to another (postgresql). I retrieve the data from oracle in chunks and drop the data to postgresql continuously. The...
1
by: querry | last post by:
Hi all, I am developing a web application where I save a XML file into a SQL Server 2000 database. I do not face any problems in storing to xml file to the database. However, when a updated...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.