473,395 Members | 2,689 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,395 software developers and data experts.

XmlDocument does not release the Xml file

Hello,
I am finding trouble while using XmlDocument class to parse my xml documents
reside in file system.

The problem is, I have a function that loads the XmlDocument and the
function is called many times during the execution context; the first call
goes ok but the second call throws the exception that 'File is being used by
another process'.

I am writing the function this way.

public void ReadXml(string path)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(path);

XmlNode node = xmlDocument.SelectSingleNode("/Employee[sal > 30]");
blah blah blah

}
any help on this would be sincerely appreciated.

Thanks in advance,
Fahad Ashfaque
Nov 12 '05 #1
1 2446
Fahad

I've not seen XmlDocument.Load cause a lock to occur before. I've only seen
it during a Save() on a multi-user app writing XML logs.

Is it possible something else in your application is fighting for contention
over the file. Are you reading or writing from streams in your application?

Glenn

"Fahad Ashfaque" <Fa***********@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
Hello,
I am finding trouble while using XmlDocument class to parse my xml documents reside in file system.

The problem is, I have a function that loads the XmlDocument and the
function is called many times during the execution context; the first call
goes ok but the second call throws the exception that 'File is being used by another process'.

I am writing the function this way.

public void ReadXml(string path)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(path);

XmlNode node = xmlDocument.SelectSingleNode("/Employee[sal > 30]");
blah blah blah

}
any help on this would be sincerely appreciated.

Thanks in advance,
Fahad Ashfaque

Nov 12 '05 #2

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

Similar topics

5
by: KathyB | last post by:
If someone could just explain this to me...I just don't get it! I have an aspx page where I retrieve several session variables and use xmlDocument to transform xml file with xsl file into an...
1
by: Shawn | last post by:
Hi. I'm using a FileStream (instead of just the path to the xml file) to load an XmlDocument. I'm doing this because I need to be able to prevent other processes to update the file I'm working on....
2
by: Adam Smith | last post by:
Hello, I have a file: test.txt: <?xml version="1.0" encoding="UTF-8"?> <First> <value>3</value> </First> I am reading it like this:
13
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...
2
by: David Withnall | last post by:
Okay I am using an XMLDocument object to process several thousands of lodgements (from a database) I am trying to output it from an XML Document to a file using the XmlDocument.WriteTo() method...
1
by: Peter Nofelt | last post by:
Hey All, I'm running into this issue with parsing through an xml document by tag name. Below is an example xml document: File Name: things.xml <things> <people> <name>Peter</name>
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... We've got a lot of places in our code where we read relatively small xml user preference blocks. Currently that's creating a new XmlDocument in every spot. I was thinking we might see...
10
by: Atara | last post by:
Suppose I have the following functions: Public Function myF1ToStream(...) As System.IO.MemoryStream . . . Dim ms As New System.IO.MemoryStream(buf) Return ms End Function Public Function...
3
by: Stephen Ward | last post by:
I have a simple little project open a xml file change a few nodes save the file, no big deal. The problem is that the doctype is getting modified when I save the file. So it looks like this:...
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: 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?
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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.