提示,好像提示:access is denied

解决方案 »

  1.   

    当Run CheckEnemyAction() 时,xmldoc.load 不成功
      

  2.   

    这是因为默认情况下不允许前台脚本按绝对路径直接操纵磁盘文件系统,以相对路径访问就可以啦
    第一个文件:test.htm
    <!--author:zangleo filename:test.htm-->
    <html>
    <head>
    <title>范例</title>
    </head>
    <script language="javascript">
    var xmldoc
    function CheckEnemyAction()
    {
       xmldoc = new ActiveXObject("Microsoft.XMLDOM");
    xmldoc.async = true;
    xmldoc.onreadystatechange = CheckState;
    xmldoc.load("test.xml");
    }function CheckState()
    {
      var state = xmldoc.readyState;
      if (state == 4)
      {
        var err = xmldoc.parseError;
        if (err.errorCode == 0)
          alert(xmldoc.xml)
      } 

    </script>
    <body>
    <input type=button value="Click" onclick="CheckEnemyAction()">
    </body>
    </html>第二个文件:test.xml
    <!--author:zangleo filename:test.xml-->
    <?xml version="1.0"?>
    <root>
    <r>HI yushinet (师) ,你好!</r>
    </root>
      

  3.   

    把xml文件放到Web服务器站点的虚拟目录中
    把本地路径换成http的方式就应该可以了吧
      

  4.   

    把xmldoc.load("C:\meyou.xml");
    改成
    xmldoc.load("C:/meyou.xml");
      

  5.   

    xmldoc.load("meyou.xml");在格式为NTFS的硬盘上出错,提示 "Access is denied"
      

  6.   

    D:\Documents and Settings\Administrator\桌面\Config.xml
    大家PP,我的查看器<html>
    <head>
    <style>
    table
    {
    border-collapse: collapse;
    border-width: 4; 
    border-style: double; 
    border-color:#15336F;
    font-size:12px;
    }
    body
    {
    font-size:12px;
    }
    div
    {
    width:100%;
    height:9; 
    border-style:solid; 
    border-width:1; 
    border-color:#eeeeee;
    vertical-align:top;
    font-size:12;
    cursor:hand;
    }
    </style>
    <title>笨狼树状节点查看器</title>
    </head>
    <body>
     <INPUT type="file" id=file1 name=file1>请输入xml文件路径
     <INPUT type="button" value="确定" onclick = "vbs:analyse ">
     <SELECT id="select1" onchange="vbs:analyse">
    <OPTION value="nodeName" >显示标签</OPTION>
    <OPTION  value="text" >显示文字</OPTION>
    <OPTION  value="attribute" >显示属性</OPTION>
     
    <OPTION  value="XPath" >显示XPath</OPTION>
    </SELECT>
    <DIV id="oList" style="padding-left:0"></DIV>
     
    </body>
     <script language="vbScript" >
    '**************************************
    '****作者: 超级大笨狼 superdullwolf****
    '**************************************
     
    public dic,favour,anything ,doc   
     
    set doc = CreateObject("Microsoft.XMLDOM")
    doc.async=False
    sub analyse()
    dim myTR 
    favour = select1.value
    removeDIV  
    if not doc.load(file1.value) then 
    alert "文件加载失败,请检查文件是否存在!"
    else
    Set rootNode = doc.DocumentElement
    set rootDIV = document.createElement("DIV")

    oList.setAttribute "XPath",rootNode.nodeName   
    oList.setAttribute "parsed",false
    appendDIV  oList,rootNode
     
     
    end if
    end sub

    sub appendDIV(myDIV,myNode)
     
    dim myChild ,newDIV,ChildID,thisID
    ChildID = 0

    for each myChild in myNode.childNodes
    set newDIV = document.createElement("DIV")
    myDIV.appendChild newDIV

    addPx newDIV, myDIV,10

    if ChildID>0 then  
    if myChild.previousSibling.nodeName <> myChild.nodeName then
      ChildID =0 
     
     end if   
    end if

    newDIV.setAttribute "XPath",getXPath(myDIV,myChild.nodeName,ChildID)
    newDIV.setAttribute "parsed",false

    newDIV.title = newDIV.getAttribute("XPath") 
    newDIV.innerText = getText(myChild,newDIV) 

    if myChild.childNodes.length>0 then 
    if  left(myChild.nodeName,1) <> "#" then
    newDIV.attachEvent "onclick",GetRef("attachOnclick") 
    end if
    end if
     ChildID = ChildID + 1
    next
    myDIV.setAttribute "parsed",true
    end sub

    function getXPath(myDIV,name,index)  
    getXPath = myDIV.getAttribute("XPath") & "/" & name & "[" & index & "]"
     
    end function

    sub removeDIV()  
    dim oldDIV
    for each  oldDIV in   oList.childNodes   
        oldDIV.removeNode(true)  
     next  
    end sub

    sub attachOnclick()
    dim obj ,nodeXPath,cDIV
    set obj=window.event.srcElement 
    nodeXPath = obj.getAttribute("XPath")
    if instr(nodeXPath,"#") >0 then 
    window.event.cancelBubble = true
    exit sub
    end if
    if not obj.getAttribute("parsed")= true then  
     appendDIV obj ,doc.selectSingleNode(nodeXPath)
    else
    for each cDIV in obj.children
    if cDIV.style.display = "none" then
    cDIV.style.display = ""
    else
    cDIV.style.display = "none"
    end if
    next
    end if
    window.event.cancelBubble = true
     
    end sub

    function getText(myNode,oDIV)
    dim myAttribute
    getText = ""
    select case favour
    case "text"
    if not isnull(myNode.text) then
    getText = myNode.text
     else
    getText = "空文字"
     end if
    case "nodeName"  
    getText = myNode.nodeName
    case "attribute"
    if left(myNode.nodeName,1) <>"#" then
    for each myAttribute in  myNode.attributes  
    getText =getText &  myAttribute.name
    getText = getText & "=" & chr(34) 
    getText = getText & myAttribute.value  & chr(34) & " "
    next
    getText = trim(getText)
    end if
        
     
    case "XPath"
    getText = oDIV.title
    end select
    if trim(getText) ="" then getText ="空"
    end function

    sub addPx(newDIV,oldDIV,num)
    dim re,myString
    set re = new RegExp
    re.Global = true
    re.Pattern = "[^\d]*"
    myString =  re.Replace(oldDIV.style.paddingLeft, "")
    if myString ="" then myString = "0"
    myString = (cint(myString) + num ) & "px"
    newDIV.style.paddingLeft = myString
    set re = nothing
    end sub
     </script>
    </html>
      

  7.   

    我就是在NTFS环境下做的啊,没有问题啊,viznet(小兔子) 你是用我给出的两个文件试的吗?