XML file error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    XML file error

    In my java scripts i am using following code.

    i am getting access denied as exception.

    I have try catch block only this part of code.

    and in other machine it is giving object error.

    strange part is in 2 machines how it can give different error?(Both are similar machines).

    code is..

    Code:
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
    xmlDoc.async="false";
    try 
    {
           xmlDoc.load("C:\\Documents and Settings\\dheeraj\\Desktop\\test.xml"); 
    }
    catch(e)
    {
          alert(e.message)
    }

    Regards
    Dheeraj Joshi
    Last edited by Dormilich; Jul 27 '09, 03:39 PM. Reason: please use [code] tags when posting code
  • Canabeez
    New Member
    • Jul 2009
    • 126

    #2
    Correct me if I'm wrong, but you cannot access local files using DOM. Only sameDomain files on the net.

    Comment

    • Dheeraj Joshi
      Recognized Expert Top Contributor
      • Jul 2009
      • 1129

      #3
      The above code works fine if this script is tested separately. But when i integrate it with a HTML page for validation it is giving the error.

      What exactly happens when i integrate it with the HTML code?

      Comment

      • jackthomas
        New Member
        • Jul 2009
        • 3

        #4
        help need

        Code:
        var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
        xmlDoc.async="false"
        xmlDoc.load("ksdjf.xml")
        
        document.write("<br>Error Code: ")
        document.write(xmlDoc.parseError.errorCode)
        document.write("<br>Error Reason: ")
        document.write(xmlDoc.parseError.reason)
        document.write("<br>Error Line: ")
        document.write(xmlDoc.parseError.line)
        <link removed>
        Last edited by Dormilich; Jul 28 '09, 05:11 PM. Reason: removed unrelated link

        Comment

        • Canabeez
          New Member
          • Jul 2009
          • 126

          #5
          Originally posted by dheerajjoshim
          The above code works fine if this script is tested separately. But when i integrate it with a HTML page for validation it is giving the error.

          What exactly happens when i integrate it with the HTML code?
          I've made and HTML file with that code on my machine (changed the link of course) - DIDN'T work for me..

          Comment

          • Dheeraj Joshi
            Recognized Expert Top Contributor
            • Jul 2009
            • 1129

            #6
            Does anybody knows what happens when we integrate it with HTML code?

            Comment

            • gits
              Recognized Expert Moderator Expert
              • May 2007
              • 5390

              #7
              what do you mean exactly with 'integrate it with HTML code'? do you test locally or from a webserver? is the XML-document served from the same domain? does all IEs have the same ActiveX-security settings etc.? how does the xml-file look like? is it valid xml?

              Comment

              • Dheeraj Joshi
                Recognized Expert Top Contributor
                • Jul 2009
                • 1129

                #8
                I got a solution to make it working.

                Comment

                • Canabeez
                  New Member
                  • Jul 2009
                  • 126

                  #9
                  Would be nice to hear it...

                  Comment

                  Working...