Jump to content

asp file contents


Stewart

Recommended Posts

i have used php to get the contents of a file stored on another server - i am trying to do the same thing in asp but i cant figure out how. my aim was to get teh contents of remote xml files and then parse them using another script i have written but i cant get the file contents in the first place

Link to comment
Share on other sites

i have used php to get the contents of a file stored on another server - i am trying to do the same thing in asp but i cant figure out how. my aim was to get teh contents of remote xml files and then parse them using another script i have written but i cant get the file contents in the first place

This is actually pretty easy:
Dim objXMLHTTP, xml, strText'Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")xml.Open "GET", "http://www.targetsite.com/somefile.xml", falsexml.SendstrText = xml.ResponseTextResponse.write(strText)Set xml = Nothing

Alternatively, you can use this:

    dim xmlDoc, isValid, strText    set xmlDoc = server.createObject("Microsoft.XMLDOM")    xmlDoc.async = false    xmlDoc.load xmlPath    isValid = cBool(xmlDoc.parseError.errorCode = 0)    if not isValid then        response.write "Invalid XML file!" & vbNewline & _               "File: " & xmlDoc.parseError.url & vbNewline & _               "Line: " & xmlDoc.parseError.line & vbNewline & _               "Character: " & xmlDoc.parseError.linepos & vbNewline & _               "Source Text: " & xmlDoc.parseError.srcText & vbNewline & _               "Description: " & xmlDoc.parseError.reason    End if    strText = xmlDoc    set xmlDoc = nothing

ASP also has functions that will parse XML automatically for you, if you'd like to use them. See this tutorial.

Link to comment
Share on other sites

yep - first version of my new RSS feeder for my page is veiwable here:http://bb.1asphost.com/atkins/rss.aspjust need to move it onto the site now (its on an intranet - i just hope the server will run it: its not exactly a recent version of IIS)atm its locked on the bbc feed, but ill sort that out later

Looks good.I'm not sure how you did your code, but here's a really simple RSS reader in Classic ASP that uses XLS transformation:http://dotnetjunkies.com/WebLog/nettricks/...02/11/6992.aspx
Link to comment
Share on other sites

oh well. i had figured out how to parse it beforehand anyway - splitiing up the item elements into an array, then create 2 other arrays for the link and title then just concatenate tehm together into a <marquee>. that way i dont have to somehow learn xsl because i could never get my head around it.im gonna do a quick rewrite now so it can accept GET requests for different feeds, and try and use dhtml to create a floating table with each <item> 's <descripton> onmouseover each feed link. it'll make a change if it works, because i can never get it totally rightanyway - thanks fopr your help

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...