用asp如何读取xml文件?
我想用这个远程的xml文件:http://mirror.tvants.com/xml/epg-public.asp用asp读取XML里面的内容,变成这样的页面:http:...
我想用这个远程的xml文件:http://mirror.tvants.com/xml/epg-public.asp
用asp读取XML里面的内容,变成这样的页面:http://live.tvren.com/nettv/tvants/tvants.asp不知道如何实现.问题解决可以再追加积分,谢谢. 展开
用asp读取XML里面的内容,变成这样的页面:http://live.tvren.com/nettv/tvants/tvants.asp不知道如何实现.问题解决可以再追加积分,谢谢. 展开
3个回答
展开全部
<style type="text/css">
body {
font-family: 宋体;
font-size: 12px;
color: #444444;
background-color: #FFFFff;
margin: 0;
padding: 0;
}
div {
border:0px solid #F00;
}
ul {
margin: 0;
padding: 5;
}
a {
color: #444444;
text-decoration: none;
line-height:150%;
padding: 1px;
}
a:hover {
color:#FF3300;
text-decoration: underline;
}
#main li {
float: left;
list-style:none;
clear:both;
width:95%;
border-bottom:1px dotted #bbb;
}
.list0 {
text-align: center;
}
.list1 {
width:85%;
float: left;
}
.list2 {
width:15%;
float: left;
}
</style>
</head>
<%
Function GetPageContent(Url)
Dim HTTPObj
On Error Resume Next
Set HTTPObj = Server.CreateObject("Microsoft.XMLHTTP")
With HTTPObj
.Open "Get", Url, False, "", ""
.Send
End With
if HTTPObj.Readystate <> 4 then
Set HTTPObj = Nothing
GetPageContent = False
Exit Function
end if
GetPageContent = replace(HTTPObj.responseText,"UTF-8","gb2312")
Set HTTPObj = Nothing
End Function
strXML=GetPageContent("http://mirror.tvants.com/xml/epg-public.asp")
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.validateonparse = true
objXML.async=false
objXML.loadXML(strXML)
set objRootElement = objXML.documentElement
if not isObject(objRootElement) then
Response.Write("no file loaded")
else
Set ChannelList=objXML.getElementsByTagName("Channel")
if isnull(objXML.getElementsByTagName("Channel") ) then
response.Write("读取失败")
response.End()
else
Set Statistics=objXML.getElementsByTagName("Statistics")
set KeywordList=objXML.getElementsbytagname("KeywordList")
response.write "<div id='main'><ul><li><span class='list0'>共有:"&keywordlist.length-1&"个频道 当前在线:"&Statistics.item(0).text&"人</span></li></ul></div>"
response.write "<div id='main'><ul>"
for j=0 to ChannelList.length-1
response.write "<li><span class='list1'>["&ChannelList.item(j).childnodes(1).text&"]<a href=http://61.234.233.249/tvantsweb/tvantsplayer.asp?id=tvants:"&ChannelList.item(j).childnodes(9).text&" target=_blank>"&ChannelList.item(j).childnodes(0).text&"</a></span><span class='list2'>"&ChannelList.item(j).childnodes(6).text&"</span></li>"
next
response.write "</ul></div>"
end if
end if
%>
你的分真难得呀.测试呀,等搞一半个上午.是用这样的方法来搞的,给你参考.!
body {
font-family: 宋体;
font-size: 12px;
color: #444444;
background-color: #FFFFff;
margin: 0;
padding: 0;
}
div {
border:0px solid #F00;
}
ul {
margin: 0;
padding: 5;
}
a {
color: #444444;
text-decoration: none;
line-height:150%;
padding: 1px;
}
a:hover {
color:#FF3300;
text-decoration: underline;
}
#main li {
float: left;
list-style:none;
clear:both;
width:95%;
border-bottom:1px dotted #bbb;
}
.list0 {
text-align: center;
}
.list1 {
width:85%;
float: left;
}
.list2 {
width:15%;
float: left;
}
</style>
</head>
<%
Function GetPageContent(Url)
Dim HTTPObj
On Error Resume Next
Set HTTPObj = Server.CreateObject("Microsoft.XMLHTTP")
With HTTPObj
.Open "Get", Url, False, "", ""
.Send
End With
if HTTPObj.Readystate <> 4 then
Set HTTPObj = Nothing
GetPageContent = False
Exit Function
end if
GetPageContent = replace(HTTPObj.responseText,"UTF-8","gb2312")
Set HTTPObj = Nothing
End Function
strXML=GetPageContent("http://mirror.tvants.com/xml/epg-public.asp")
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.validateonparse = true
objXML.async=false
objXML.loadXML(strXML)
set objRootElement = objXML.documentElement
if not isObject(objRootElement) then
Response.Write("no file loaded")
else
Set ChannelList=objXML.getElementsByTagName("Channel")
if isnull(objXML.getElementsByTagName("Channel") ) then
response.Write("读取失败")
response.End()
else
Set Statistics=objXML.getElementsByTagName("Statistics")
set KeywordList=objXML.getElementsbytagname("KeywordList")
response.write "<div id='main'><ul><li><span class='list0'>共有:"&keywordlist.length-1&"个频道 当前在线:"&Statistics.item(0).text&"人</span></li></ul></div>"
response.write "<div id='main'><ul>"
for j=0 to ChannelList.length-1
response.write "<li><span class='list1'>["&ChannelList.item(j).childnodes(1).text&"]<a href=http://61.234.233.249/tvantsweb/tvantsplayer.asp?id=tvants:"&ChannelList.item(j).childnodes(9).text&" target=_blank>"&ChannelList.item(j).childnodes(0).text&"</a></span><span class='list2'>"&ChannelList.item(j).childnodes(6).text&"</span></li>"
next
response.write "</ul></div>"
end if
end if
%>
你的分真难得呀.测试呀,等搞一半个上午.是用这样的方法来搞的,给你参考.!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
:)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询