用asp如何读取xml文件?
发布网友
发布时间:2022-04-29 12:47
我来回答
共3个回答
热心网友
时间:2022-06-28 02:49
<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
%>
你的分真难得呀.测试呀,等搞一半个上午.是用这样的方法来搞的,给你参考.!
热心网友
时间:2022-06-28 02:49
http://61.234.233.249/tvantsweb/tvants.asp
热心网友
时间:2022-06-28 02:50
:)