xmlDOM的问题

anycon 2004-07-19 10:03:30
<%
Set doc=Server.CreateObject("Microsoft.XMLDOM")
doc.async=false
doc.Load("livescore_xml.asp")
Set objRootNode=doc.documentElement

for each objNodeList in objRootNode.childNodes
Response.Write("<tr/><td align=center />"&objNodeList.selectSingleNode("LeagueName").text)
Response.Write("<td align=center />"&objNodeList.selectSingleNode("DateMatch").text)
Response.Write("<td align=center />"&objNodeList.selectSingleNode("HomeTeam").text)
Response.Write("<td align=center />"&objNodeList.selectSingleNode("AwayTeam").text)

next
set doc=nothing
%>


为什么运行时IE报以下错误,是否错误在这一行"for each objNodeList in objRootNode.childNodes",应该如何改???:

Technical Information (for support personnel)

Error Type:
Microsoft VBScript 运行时错误 (0x800A01A8)
缺少对象
/score/x.asp, line 60


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; MyIE2)

Page:
GET /score/x.asp

Time:
2004年7月19日, 10:00:35


...全文
179 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
Laone 2004-07-19
  • 打赏
  • 举报
回复
xml encoding错误了,请确认你的xml文件是否正确
anycon 2004-07-19
  • 打赏
  • 举报
回复
IE有如下报错,什么意思??

A name was started with an invalid character.
anycon 2004-07-19
  • 打赏
  • 举报
回复
TO ssm1226(雨中人*www.dncc.net*)
用你上述方法
IE有如下报错

Error Type:
Microsoft VBScript 编译器错误 (0x800A0414)
调用子程序时不能使用括号
/score/x.asp, line 40, column 42
doc.setProperty("ServerHTTPRequest", true)
-----------------------------------------^
ssm1226 2004-07-19
  • 打赏
  • 举报
回复
sorry,刚才注意load的是asp文件:(

用上面的方法即可
ssm1226 2004-07-19
  • 打赏
  • 举报
回复
doc.setProperty("ServerHTTPRequest", true)
if not doc.load("livescore.asp") then
'error
end if
anycon 2004-07-19
  • 打赏
  • 举报
回复
用doc.Load(Server.mappath("livescore.xml"))
没有错误,但是换用livescore.asp内嵌的xml时出错了?
应如何装载livescore.asp生成的xml代码?????
xzq686 2004-07-19
  • 打赏
  • 举报
回复
确认LeagueName,DateMatch等是否写正确。。。
livescore_xml.asp文件名是否正确。。
ssm1226 2004-07-19
  • 打赏
  • 举报
回复
另外,确认循环中 各objNodeList.selectSingleNode("..")节点都存在!
ssm1226 2004-07-19
  • 打赏
  • 举报
回复
if not doc.Load(server.mappath("livescore_xml.asp")) then
response.write doc.parseError.reason
response.end
end if
anycon 2004-07-19
  • 打赏
  • 举报
回复
我估计也是装载livescore_xml.asp生成的xml代码失败
这个路径是怎么分别为什么有时用doc.Load(Server.mappath("livescore_xml.asp"))
有时用doc.Load(livescore_xml.asp)也可
anycon 2004-07-19
  • 打赏
  • 举报
回复
请教ssm1226(雨中人*www.dncc.net*) :
doc.Load(Server.mappath("livescore_xml.asp"))

doc.Load(livescore_xml.asp)

两者区别在哪?

用doc.Load(Server.mappath("livescore_xml.asp"))还是那个错误
ssm1226 2004-07-19
  • 打赏
  • 举报
回复
doc.Load(Server.mappath("livescore_xml.asp"))
ssm1226 2004-07-19
  • 打赏
  • 举报
回复
这样试试,注意,两个是同一行,不要换行!
<%@ Language=VBScript %><?xml version='1.0' encoding='gb2312'?>
anycon 2004-07-19
  • 打赏
  • 举报
回复
整理一下:


<%@ Language=VBScript %>
<% Option Explicit %>
<%
Function getConString()
Const cstrServer = "localhost"
Const cstrDatabase = "sb"
Const cstrUserID = "sa"
Const cstrPassword = ""

getConString = "Provider=SQLOLEDB.1; Data Source=" & cstrServer & "; Initial Catalog=" & cstrDatabase & "; User ID=" & cstrUserID & "; Password=" & cstrPassword & ";"

End Function


Function CloseADO(ByRef Obj)
If Not IsEmpty(Obj) Then
If Not Obj Is Nothing Then
If Obj.State <> 0 Then Obj.Close
Set Obj = Nothing
End If
End If
End Function

%>

<%
Dim conDB, strViewDate, strMatchDesc,strCurrentDate,strSQL,strLeagueSQL,strHomeSQL,strAwaySQL,rstMatch,rstLeague,rstHome,rstAway
Set conDB = Server.CreateObject("ADODB.Connection")
conDB.Open getConString()
strSQL="SELECT * FROM tblMatch WHERE CONVERT(VARCHAR(24), DateMatch, 111)=CONVERT(VARCHAR(24),getdate(), 111)"
Set rstMatch = Server.CreateObject("ADODB.Recordset")
rstMatch.Open strSQL, conDB, 3, 3

If Not rstMatch.EOF Then
%>
<?xml version="1.0" encoding="GB2312"?>
<livescore>
<%
While Not rstMatch.EOF
'--get fields from tblMatch

Dim LeagueCode,MatchNo,Date1stHalfEnd,Date2ndHalfStart,Date2ndHalfEnd,DateMatch
Dim ScoreHome,ScoreAway,ScoreHome1stHalf,ScoreAway1stHalf,TeamCodeAway,TeamCodeHome,rstScore,strScoreSQL
LeagueCode=rstMatch("LeagueCode")
MatchNo=rstMatch("MatchNo")
Date1stHalfEnd=rstMatch("Date1stHalfEnd")
Date2ndHalfStart=rstMatch("Date2ndHalfStart")
Date2ndHalfEnd=rstMatch("Date2ndHalfEnd")
DateMatch=rstMatch("DateMatch")
ScoreHome=rstMatch("ScoreHome")
ScoreAway=rstMatch("ScoreAway")
ScoreHome1stHalf=rstMatch("ScoreHome1stHalf")
ScoreAway1stHalf=rstMatch("ScoreAway1stHalf")
TeamCodeAway=rstMatch("TeamCodeAway")
TeamCodeHome=rstMatch("TeamCodeHome")

If Not rstScore.EOF Then
Dim DateScore,ScoreHomeRealTime,ScoreAwayRealTime
DateScore=rstScore("DateScore")
ScoreHomeRealTime=rstScore("ScoreHome")
ScoreAwayRealTime=rstScore("ScoreAway")
End If
%>
<Match>
<MatchNo><%=MatchNo%></MatchNo>
<Date1stHalfEnd><%=Date1stHalfEnd%></Date1stHalfEnd>
<Date2ndHalfStart><%=Date2ndHalfStart%></Date2ndHalfStart>
<Date2ndHalfEnd><%=Date2ndHalfEnd%></Date2ndHalfEnd>
<DateMatch><%=DateMatch%></DateMatch>
<ScoreHome><%=ScoreHome%></ScoreHome>
<ScoreAway><%=ScoreAway%></ScoreAway>
<ScoreHome1stHalf><%=ScoreHome1stHalf%></ScoreHome1stHalf>
</Match>
<%

rstMatch.MoveNext()
Call CloseADO(rstLeague)
Call CloseADO(rstHome)
Call CloseADO(rstAway)
Call CloseADO(rstScore)
Wend

%>
</livescore>
<%
Else

End If

Call CloseADO(conDB)

%>
anycon 2004-07-19
  • 打赏
  • 举报
回复
livescore_xml.asp如下

<%@ Language=VBScript %>
<% Option Explicit %>
<%
Function getConString()
Const cstrServer = "localhost"
Const cstrDatabase = "sb"
Const cstrUserID = "sa"
Const cstrPassword = ""

getConString = "Provider=SQLOLEDB.1; Data Source=" & cstrServer & "; Initial Catalog=" & cstrDatabase & "; User ID=" & cstrUserID & "; Password=" & cstrPassword & ";"

If Trim(Session("pServer")) <> "" And Trim(Session("pDatabase")) <> "" Then
getConString = "Provider=SQLOLEDB.1; Data Source=" & Session("pServer") & "; Initial Catalog=" & Session("pDatabase") & "; User ID=" & Session("pUserID") & "; Password=" & Session("pPassword") & ";"
End If
End Function


Function CloseADO(ByRef Obj)
If Not IsEmpty(Obj) Then
If Not Obj Is Nothing Then
If Obj.State <> 0 Then Obj.Close
Set Obj = Nothing
End If
End If
End Function

%>

<%
Dim conDB, strViewDate, strMatchDesc,strCurrentDate,strSQL,strLeagueSQL,strHomeSQL,strAwaySQL,rstMatch,rstLeague,rstHome,rstAway
Set conDB = Server.CreateObject("ADODB.Connection")
conDB.Open getConString()
strSQL="SELECT * FROM tblMatch WHERE CONVERT(VARCHAR(24), DateMatch, 111)=CONVERT(VARCHAR(24),getdate(), 111)"
Set rstMatch = Server.CreateObject("ADODB.Recordset")
rstMatch.Open strSQL, conDB, 3, 3

If Not rstMatch.EOF Then
%>
<?xml version="1.0" encoding="GB2312"?>
<livescore>
<%
While Not rstMatch.EOF
'--get fields from tblMatch

Dim LeagueCode,MatchNo,Date1stHalfEnd,Date2ndHalfStart,Date2ndHalfEnd,DateMatch
Dim ScoreHome,ScoreAway,ScoreHome1stHalf,ScoreAway1stHalf,TeamCodeAway,TeamCodeHome,rstScore,strScoreSQL
LeagueCode=rstMatch("LeagueCode")
MatchNo=rstMatch("MatchNo")
Date1stHalfEnd=rstMatch("Date1stHalfEnd")
Date2ndHalfStart=rstMatch("Date2ndHalfStart")
Date2ndHalfEnd=rstMatch("Date2ndHalfEnd")
DateMatch=rstMatch("DateMatch")
ScoreHome=rstMatch("ScoreHome")
ScoreAway=rstMatch("ScoreAway")
ScoreHome1stHalf=rstMatch("ScoreHome1stHalf")
ScoreAway1stHalf=rstMatch("ScoreAway1stHalf")
TeamCodeAway=rstMatch("TeamCodeAway")
TeamCodeHome=rstMatch("TeamCodeHome")

If Not rstScore.EOF Then
Dim DateScore,ScoreHomeRealTime,ScoreAwayRealTime
DateScore=rstScore("DateScore")
ScoreHomeRealTime=rstScore("ScoreHome")
ScoreAwayRealTime=rstScore("ScoreAway")
End If
%>
<Match>
<MatchNo><%=MatchNo%></MatchNo>
<Date1stHalfEnd><%=Date1stHalfEnd%></Date1stHalfEnd>
<Date2ndHalfStart><%=Date2ndHalfStart%></Date2ndHalfStart>
<Date2ndHalfEnd><%=Date2ndHalfEnd%></Date2ndHalfEnd>
<DateMatch><%=DateMatch%></DateMatch>
<ScoreHome><%=ScoreHome%></ScoreHome>
<ScoreAway><%=ScoreAway%></ScoreAway>
<ScoreHome1stHalf><%=ScoreHome1stHalf%></ScoreHome1stHalf>
</Match>
<%

rstMatch.MoveNext()
Call CloseADO(rstLeague)
Call CloseADO(rstHome)
Call CloseADO(rstAway)
Call CloseADO(rstScore)
Wend

%>
</livescore>
<%
Else
%>

<?xml version="1.0" encoding="GB2312"?>
<livescore>
<Match>
<MatchNo>No Record</MatchNo>
<Date1stHalfEnd>No Record</Date1stHalfEnd>
<Date2ndHalfStart>No Record</Date2ndHalfStart>
<Date2ndHalfEnd>No Record</Date2ndHalfEnd>
<DateMatch>No Record</DateMatch>
<ScoreHome>No Record</ScoreHome>
<ScoreAway>No Record</ScoreAway>
<ScoreHome1stHalf>No Record</ScoreHome1stHalf>
<ScoreAway1stHalf>No Record</ScoreAway1stHalf>
<LeagueName>No Record</LeagueName>
<HomeTeam>No Record</HomeTeam>
<AwayTeam>No Record</AwayTeam>
<DateScore>No Record</DateScore>
<ScoreHomeRealTime>No Record</ScoreHomeRealTime>
<ScoreAwayRealTime>No Record</ScoreAwayRealTime>
</Match>
</livescore>
<%
End If

Call CloseADO(conDB)

%>
ssm1226 2004-07-19
  • 打赏
  • 举报
回复
livescore.asp文件中加入:

Response.charset="gb2312"
Response.clear()


-----------------------------------
你是怎样生成XML文件的?
ssm1226 2004-07-19
  • 打赏
  • 举报
回复
看看错误信息嘛: 调用子程序时不能使用括号

把括号去掉就可以了:)


doc.setProperty("ServerHTTPRequest", true)

==>

doc.setProperty "ServerHTTPRequest", true

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧