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

read-only loading of an XML

I use Microsoft.XMLDOM load() method to load an XML file into memory
and display
some elements in the browser.

However it apparently locks the file, since I get this error message
whenever a Visual Basic application concurrently tries to add an
element to the same XML file:

The process cannot access the file because it is being used by another
process.

I would like not to lock this file, but open it in read-only mode
instead. In fact the browser simply needs to read its content, it
doesn't need to modify it at all. As a consequence there is no reason
to lock it.

At the same time, I need to access it from the VB process.

Any suggestion?

Cheers
Jul 23 '05 #1
5 4365


floods wrote:
I use Microsoft.XMLDOM load() method to load an XML file into memory
and display
some elements in the browser.

However it apparently locks the file, since I get this error message
whenever a Visual Basic application concurrently tries to add an
element to the same XML file:

The process cannot access the file because it is being used by another
process.

I would like not to lock this file, but open it in read-only mode
instead. In fact the browser simply needs to read its content, it
doesn't need to modify it at all. As a consequence there is no reason
to lock it.

At the same time, I need to access it from the VB process.

Any suggestion?


Can't you use a local HTTP server and load the file from
http://localhost/dir/file.xml
?
I am astonished that loading a file with Microsoft.XMLDOM locks it but I
can only imagine that that happens when you load directly from the file
system.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41***********************@newsread4.arcor-online.net>...
floods wrote:
I use Microsoft.XMLDOM load() method to load an XML file into memory
and display some elements in the browser.

[...]

I would like not to lock this file, but open it in read-only mode
instead.

Can't you use a local HTTP server and load the file from
http://localhost/dir/file.xml
?
I am astonished that loading a file with Microsoft.XMLDOM locks it but I
can only imagine that that happens when you load directly from the file
system.


I would prefer not because I don't like starting a Web server just to
read an XML file.

That machine should only collect some data. The only reason I want to
access the XML file is monitoring.

Thanks, Davide
Jul 23 '05 #3


floods wrote:

Can't you use a local HTTP server and load the file from
http://localhost/dir/file.xml
?
I am astonished that loading a file with Microsoft.XMLDOM locks it but I
can only imagine that that happens when you load directly from the file
system.

I would prefer not because I don't like starting a Web server just to
read an XML file.


You might want to try to load the XML as follows:

function getXMLDocument (file) {
var xmlDocument1 = new ActiveXObject('Microsoft.XMLDOM');
var xmlDocument2 = new ActiveXObject('Microsoft.XMLDOM');
xmlDocument1.async = false;
xmlDocument1.load(file);
xmlDocument2.load(xmlDocument1);
return xmlDocument2;
}

var xmlDocument = getXMLDocument('test2004112201.xml');

maybe that way the XML file is no longer blocked. Let us know whether
that works.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41***********************@newsread2.arcor-online.net>...
You might want to try to load the XML as follows:

function getXMLDocument (file) {
var xmlDocument1 = new ActiveXObject('Microsoft.XMLDOM');
var xmlDocument2 = new ActiveXObject('Microsoft.XMLDOM');
xmlDocument1.async = false;
xmlDocument1.load(file);
xmlDocument2.load(xmlDocument1);
return xmlDocument2;
}

var xmlDocument = getXMLDocument('test2004112201.xml');

maybe that way the XML file is no longer blocked.


The file is not blocked permanently. It seems it is blocked only
during its loading. As soon as it is loaded, the 2nd application can
write on it without any problem. However if it happens that this 2nd
application accesses the XML file while it is being loaded by the
browser, then the problem arises.

As a consequence, the problem is there even if I use getXMLDocument().
In fact it would appear in the same manner if the 2nd application
accessed the XML while the javascript was performing the
"xmlDocument1.load(file)" instruction.

Cheers,

Davide
Jul 23 '05 #5
Try using loadXml method instead of load. For this you will have to
open the file using some file system IO funtion and here you can open
as read-only. Then read all the XML in it and pass it to loadXml. Am
coding in C# so don't have the javascript syntax handy.

Regards
Dhananjay

fl****@libero.it (floods) wrote in message news:<34**************************@posting.google. com>...
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41***********************@newsread2.arcor-online.net>...
You might want to try to load the XML as follows:

function getXMLDocument (file) {
var xmlDocument1 = new ActiveXObject('Microsoft.XMLDOM');
var xmlDocument2 = new ActiveXObject('Microsoft.XMLDOM');
xmlDocument1.async = false;
xmlDocument1.load(file);
xmlDocument2.load(xmlDocument1);
return xmlDocument2;
}

var xmlDocument = getXMLDocument('test2004112201.xml');

maybe that way the XML file is no longer blocked.


The file is not blocked permanently. It seems it is blocked only
during its loading. As soon as it is loaded, the 2nd application can
write on it without any problem. However if it happens that this 2nd
application accesses the XML file while it is being loaded by the
browser, then the problem arises.

As a consequence, the problem is there even if I use getXMLDocument().
In fact it would appear in the same manner if the 2nd application
accessed the XML while the javascript was performing the
"xmlDocument1.load(file)" instruction.

Cheers,

Davide

Jul 23 '05 #6

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

Similar topics

2
by: Gunnar | last post by:
Hello, I've just written a CPP program that reads integers from a binary file, and used this code while (my_ifstram.read( (char* ) &number, sizeof(int)) { // do something with number } My...
6
by: Steve | last post by:
Hi, I'm trying to convert a file reading loop into one using streams. The BSD OS read API returns the number of bytes read, but istream::read returns itself. How can I find out the number of...
12
by: Steven T. Hatton | last post by:
I know of a least one person who believes std::ifstream::read() and std::ofstream::write() are "mistakes". They seem to do the job I want done. What's wrong with them. This is the code I...
2
by: Sandman | last post by:
Just looking for suggestion on how to do this in my Web application. The goal is to keep track of what a user has and hasn't read and present him or her with new material I am currently doing...
4
by: Ollie Cook | last post by:
Hi, I am having some difficulty with read(2) and interrupting signals. I expect I am misunderstanding how the two work together, so would appreciate some guidance. I am trying to 'time out' a...
1
by: Jose Reckoner | last post by:
I'm running python 2.3 on Windows XP. Anyone have a quick small script to convert .DT1 and .DEM data to ASCII or some other format? I don't need a viewer. Thanks!
0
by: phplasma | last post by:
Hey, I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express. I have successfully made...
6
by: arnuld | last post by:
This works fine, I welcome any views/advices/coding-practices :) /* C++ Primer - 4/e * * Exercise 8.9 * STATEMENT: * write a program to store each line from a file into a *...
4
by: zl2k | last post by:
hi, there I have a appendable binary file of complex data structure named data.bin created by myself. It is written in the following format: number of Data, Data array Suppose I have...
5
by: Thomas Christensen | last post by:
This issue has been raised a couple of times I am sure. But I have yet to find a satisfying answer. I am reading from a subprocess and this subprocess sometimes hang, in which case a call to...
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
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: 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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.