從here: XML:如何使用vbscript和經典asp在xml中選擇SingleNode?
<Vocabulary>
<Word type="noun" level="1">
<English>cat</English>
<Spanish>gato</Spanish>
</Word>
<Word type="verb" level="1">
<English>speak</English>
<Spanish>hablar</Spanish>
</Word>
<Word type="adj" level="1">
<English>big</English>
<Spanish>grande</Spanish>
</Word>
</Vocabulary>
我創建的XML文件把它放在同一個目錄中經典的asp文件:
<%
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("vocabulary.xml")
Set Node = objXMLDoc.documentElement.selectSingleNode("Word/Spanish")
document.write(Node.text)
%>
但我得到這個:
微軟的VBScript運行時錯誤「800a01a8」
所需對象:'objXMLDoc.documentElement'
/so-rms/reports/xmltest.asp,7號線
我在做什麼錯?他們得到的元素。我收到錯誤。謝謝。
編輯:我把這個在:
If objXMLDoc.parseError.errorCode <> 0 Then
response.write objXMLDoc.parseError.errorCode & "ERROR CODE </br>"
response.write objXMLDoc.parseError.reason & "REASON CODE </br>"
response.write objXMLDoc.parseError.line & "LINE CODE </br>"
End If
,並得到:
-2146697210ERROR CODE
系統錯誤:-2146697210。原因碼
0LINE CODE 從下面的嘗試:
dim path: path = Server.MapPath("vocabulary.xml")
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(path) then
Response.Write "path '" & path & "' not found"
end if
Set objXMLDoc = CreateObject("MSXML2.DOMDocument.3.0")
objXMLDoc.async = False
if not objXMLDoc.load("vocabulary.xml") then
' report loading error
response.write "error"
end if
'objXMLDoc.load("vocabulary.xml")
If objXMLDoc.parseError.errorCode <> 0 Then
response.write objXMLDoc.parseError.errorCode & "ERROR CODE </br>"
response.write objXMLDoc.parseError.reason & "REASON CODE </br>"
response.write objXMLDoc.parseError.line & "LINE CODE </br>"
End If
Set Node = objXMLDoc.documentElement.selectSingleNode("Word/Spanish")
document.write(Node.text)
編輯:
我也改變了xml文件工作XML返回的URL(Bing地圖)和它的工作。所以我猜這是文件。謝謝。
你試過'objXMLDoc.load(路徑)',其中'path'是調用'MapPath()'的結果? – 2011-08-30 18:22:08