read-only loading of an XML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • floods

    #1

    read-only loading of an XML

    I use Microsoft.XMLDO M 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
  • Martin Honnen

    #2
    Re: read-only loading of an XML



    floods wrote:
    [color=blue]
    > I use Microsoft.XMLDO M 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?[/color]

    Can't you use a local HTTP server and load the file from

    ?
    I am astonished that loading a file with Microsoft.XMLDO M locks it but I
    can only imagine that that happens when you load directly from the file
    system.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • floods

      #3
      Re: read-only loading of an XML

      Martin Honnen <mahotrash@yaho o.de> wrote in message news:<41a21179$ 0$16041$9b4e6d9 3@newsread4.arc or-online.net>...[color=blue]
      > floods wrote:
      >[color=green]
      > > I use Microsoft.XMLDO M 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.[/color]
      >
      >
      > 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.XMLDO M locks it but I
      > can only imagine that that happens when you load directly from the file
      > system.[/color]

      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

      Comment

      • Martin Honnen

        #4
        Re: read-only loading of an XML



        floods wrote:

        [color=blue][color=green]
        >>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.XMLDO M locks it but I
        >>can only imagine that that happens when you load directly from the file
        >>system.[/color]
        >
        >
        > I would prefer not because I don't like starting a Web server just to
        > read an XML file.[/color]

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

        function getXMLDocument (file) {
        var xmlDocument1 = new ActiveXObject(' Microsoft.XMLDO M');
        var xmlDocument2 = new ActiveXObject(' Microsoft.XMLDO M');
        xmlDocument1.as ync = false;
        xmlDocument1.lo ad(file);
        xmlDocument2.lo ad(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/

        Comment

        • floods

          #5
          Re: read-only loading of an XML

          Martin Honnen <mahotrash@yaho o.de> wrote in message news:<41a32857$ 0$29849$9b4e6d9 3@newsread2.arc or-online.net>...
          [color=blue]
          > You might want to try to load the XML as follows:
          >
          > function getXMLDocument (file) {
          > var xmlDocument1 = new ActiveXObject(' Microsoft.XMLDO M');
          > var xmlDocument2 = new ActiveXObject(' Microsoft.XMLDO M');
          > xmlDocument1.as ync = false;
          > xmlDocument1.lo ad(file);
          > xmlDocument2.lo ad(xmlDocument1 );
          > return xmlDocument2;
          > }
          >
          > var xmlDocument = getXMLDocument( 'test2004112201 .xml');
          >
          > maybe that way the XML file is no longer blocked.[/color]

          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.l oad(file)" instruction.

          Cheers,

          Davide

          Comment

          • Dhananjay

            #6
            Re: read-only loading of an XML

            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

            floods@libero.i t (floods) wrote in message news:<3456adb1. 0411240507.365b eee5@posting.go ogle.com>...[color=blue]
            > Martin Honnen <mahotrash@yaho o.de> wrote in message news:<41a32857$ 0$29849$9b4e6d9 3@newsread2.arc or-online.net>...
            >[color=green]
            > > You might want to try to load the XML as follows:
            > >
            > > function getXMLDocument (file) {
            > > var xmlDocument1 = new ActiveXObject(' Microsoft.XMLDO M');
            > > var xmlDocument2 = new ActiveXObject(' Microsoft.XMLDO M');
            > > xmlDocument1.as ync = false;
            > > xmlDocument1.lo ad(file);
            > > xmlDocument2.lo ad(xmlDocument1 );
            > > return xmlDocument2;
            > > }
            > >
            > > var xmlDocument = getXMLDocument( 'test2004112201 .xml');
            > >
            > > maybe that way the XML file is no longer blocked.[/color]
            >
            > 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.l oad(file)" instruction.
            >
            > Cheers,
            >
            > Davide[/color]

            Comment

            Working...