read-only loading of an XML

F

floods

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
 
M

Martin Honnen

floods said:
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.
 
F

floods

Martin Honnen said:
floods said:
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
 
M

Martin Honnen

floods wrote:

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.
 
F

floods

Martin Honnen said:
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
 
D

Dhananjay

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top