SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unsual? XML feed to display

    Hi

    I'm trying to display a XMl feed in ASP classic

    I've tried adapting a script I found online which works for the feed: http://rss.news.yahoo.com/rss/tech

    <%
    Call getNews(10)

    Sub getNEWS(howManyResults)
    myRSSfile = "http://rss.news.yahoo.com/rss/tech"

    Set xmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
    xmlHttp.Open "Get", myRSSfile, false
    xmlHttp.Send
    myXML = xmlHttp.ResponseText

    Set xmlResponse = Server.CreateObject("MSXML2.DomDocument.6.0")
    xmlResponse.async = false
    xmlResponse.LoadXml(myXML)
    Set xmlHttp = Nothing

    Set objLst = xmlResponse.getElementsByTagName("item")
    Set xmlResponse = Nothing

    intNoOfHeadlines = objLst.length -1

    For i = 0 To (intNoOfHeadlines)
    Set objHdl = objLst.item(i)

    for each child in objHdl.childNodes
    Select case lcase(child.nodeName)
    case "title"
    title = child.text
    case "link"
    link = child.text
    case "description"
    description = child.text
    'You can also use the following: author,category,comments,enclosure,guid,pubDate,source
    End Select
    next

    kk = kk+1
    if kk < howManyresults+1 then
    Response.Write "" & title & "<br />" & link & " <br> " & description & ""

    end if

    Next
    End Sub
    %>
    Now a sample of the XML feed I need to get it to work with is:

    <?xml version='1.0' encoding='utf-8'?>
    <Diary>
    <Event EventName="3.10 Hamilton" ClassificationID="2" Classification="Horse Racing" EventStart="2013-09-23T15:10:00+01:00" EventEnd="2013-09-23T16:20:00+01:00" Streaming="1" BlockedCountryCodes="AU#CY#FR#HK#NZ#SG#US#AX#UM" EventGroup="Hamilton"/><Event EventName="3.40 Hamilton" ClassificationID="2" Classification="Horse Racing" EventStart="2013-09-23T15:40:00+01:00" EventEnd="2013-09-23T16:40:00+01:00" Streaming="1" BlockedCountryCodes="AU#CY#FR#HK#NZ#SG#US#AX#UM" EventGroup="Hamilton"/><Event EventName="3.50 Kempton" ClassificationID="2" Classification="Horse Racing" EventStart="2013-09-23T15:50:00+01:00" EventEnd="2013-09-23T16:02:18.537+01:00" Streaming="1" BlockedCountryCodes="AU#CY#FR#HK#NZ#SG#US#AX#UM" EventGroup="Kempton"/><Event EventName="4.00 Leicester" ClassificationID="2" Classification="Horse Racing" EventStart="2013-09-23T16:00:00+01:00" EventEnd="2013-09-23T17:00:00+01:00" Streaming="1" BlockedCountryCodes="AG#AU#BS#BB#BZ#CU#CY#DM#DO#GD#GY#HT#HK#IN#IL#JM#JP#NZ#KN#LC#VC#SR" EventGroup="Leicester"/>
    </Diary>
    I've experimented with the following amendments but I only end up getting a blank page (I've tried different tagnames such as 'Diary' 'Event' etc), is there anyway of amending the code so it works with the feed?

    <%
    Call getNews(10)

    Sub getNEWS(howManyResults)
    myRSSfile = "http://www.watchlivefootball.com/xml-test.xml"

    Set xmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
    xmlHttp.Open "Get", myRSSfile, false
    xmlHttp.Send
    myXML = xmlHttp.ResponseText

    Set xmlResponse = Server.CreateObject("MSXML2.DomDocument.6.0")
    xmlResponse.async = false
    xmlResponse.LoadXml(myXML)
    Set xmlHttp = Nothing

    Set objLst = xmlResponse.getElementsByTagName("Event")
    Set xmlResponse = Nothing

    intNoOfHeadlines = objLst.length -1

    For i = 0 To (intNoOfHeadlines)
    Set objHdl = objLst.item(i)

    for each child in objHdl.childNodes
    Select case lcase(child.nodeName)
    case "EventName"
    title = child.text
    case "Classification"
    link = child.text
    case "EventStart"
    description = child.text
    'You can also use the following: author,category,comments,enclosure,guid,pubDate,source
    End Select
    next

    kk = kk+1
    if kk < howManyresults+1 then
    Response.Write "<br /><a href=""" & link & """>" & title & "</a> <br> " & description

    end if

    Next
    End Sub
    %>

  2. #2
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay i was able to figure out the code for retriving the attribute info and filter out the results by a catergory

    <%
    myRSSfile = "http://www.watchlivefootball.com/xml-test.xml"
    Dim OutputHTML_1,OutputHTML_2

    Set xmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
    xmlHttp.Open "Get", myRSSfile, false
    xmlHttp.Send
    myXML = xmlHttp.ResponseText

    Set oXML = Server.CreateObject("MSXML2.DomDocument.6.0")
    oXML.async = false
    oXML.LoadXml(myXML)
    Set xmlHttp = Nothing


    For Each oNode In oXML.SelectNodes("/Diary/Event")
    sEventName = oNode.GetAttribute("EventName")
    sID = oNode.GetAttribute("ID")
    sStart = oNode.GetAttribute("EventStart")
    sGroup = oNode.GetAttribute("EventGroup")
    sType = oNode.GetAttribute("Classification")




    // now check filter
    If (InStr(sType,Soccer)>0) then

    OutputHTML_1 = OutputHTML_1 & "<tr><td>" & sStart & "</td><td>" & sEventName & "</td><td>" & sGroup & "</td></tr>"

    End if
    Next

    Set oXML = Nothing

    %>

    Trouble I have now is the date/time format is in ISO8601 standard (i.e. 2013-09-26T12:30:00+01:00) is there any easy way of converting/striping the string so I can display just the time (12:30)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •