format a retrieved text file

R

Robb Meade

...
I just learned that it is possible to grab a text file from another
site and display the data on my own site, however when I display the
data it does not format it correctly. Can anyone please point me in
the direction of a tutorial or help me with the code below.

Hi John,

I've often wanted to know how to do this also, so cheers for the code, might
come in handy...

With regards to the formatting it looks like its dropped all of the carriage
returns and stuff, just wondered, what would happen if you grabbed the file
from their site and then saved it as a text file on your own - when you open
the text file then, do you still have the correct formatting, or is it being
lost when the XML stuff reads it in?

Robb
 
R

Robb Meade

...

[snip]

Hi John,

In addition to that, I've just tried the same code with the same file and
got what you had...however, I then pointed it to a text file on my own
server...

http://80.195.95.105/xml-get-test.asp

the results came out fine...maybe its something to do with the way that
their text file has been written, maybe there are no carriage returns (is
that possible) in their file?

Try it with some of your own text files and see what happens...as far as the
code goes it 'seems' to be working correctly.

Regards

Robb
 
J

John

I just learned that it is possible to grab a text file from another
site and display the data on my own site, however when I display the
data it does not format it correctly. Can anyone please point me in
the direction of a tutorial or help me with the code below.

John

<%
Response.Buffer = True
Dim objXMLHTTP, xml


Set xml = Server.CreateObject("Microsoft.XMLHTTP")

xml.Open "GET",
"http://iwin.nws.noaa.gov/pub/data/text/FZUS53/KCLE.TXT", False

xml.Send

Response.Write xml.responseText

Set xml = Nothing
%>

This is a sample of what I am getting back
FZUS61 KCLE 291114 AAA GLFLE LEZ160-291400- OPEN LAKE FORECAST FOR
LAKE ERIE...UPDATED NATIONAL WEATHER SERVICE CLEVELAND OH 700 AM EDT
SUN JUN 29 2003 UPDATED FOR SHOWERS LAKE ERIE FORECAST BEYOND FIVE
NAUTICAL MILES FROM SHORE .SYNOPSIS...A COLD FRONT NORTHWEST OF LAKE
ERIE WILL MOVE SOUTHEAST ACROSS THE LAKE THIS AFTERNOON AND EARLY THIS
EVENING. HIGH PRESSURE 30.10 INCHES OVER THE CENTRAL PLAINS WILL BUILD
ACROSS THE LAKE BEHIND THE FRONT MONDAY AND TUESDAY. THE HIGH WIL

this is what i get if i connect to the page directly (and what I would
like to see with my results

FZUS61 KCLE 291114 AAA
GLFLE
LEZ160-291400-


OPEN LAKE FORECAST FOR LAKE ERIE...UPDATED
NATIONAL WEATHER SERVICE CLEVELAND OH
700 AM EDT SUN JUN 29 2003

UPDATED FOR SHOWERS

LAKE ERIE FORECAST BEYOND FIVE NAUTICAL MILES FROM SHORE

SYNOPSIS
A COLD FRONT NORTHWEST OF LAKE ERIE WILL MOVE SOUTHEAST
ACROSS THE LAKE THIS AFTERNOON AND EARLY THIS EVENING. HIGH
PRESSURE 30.10 INCHES OVER THE CENTRAL PLAINS WILL BUILD ACROSS THE
LAKE BEHIND THE FRONT MONDAY AND TUESDAY. THE HIGH WILL MOVE EAST
OF THE AREA WEDNESDAY BUT SHOULD CONTINUE TO INFLUENCE WEATHER OVER
THE LAKE THROUGH THURSDAY.
 
R

Robb Meade

...
the results came out fine...

correction - it looked like it - but then I changed the contents of the text
file and now it isnt...its definately something to do with the carriage
returns!

Sorry :(
 
E

Evertjan.

John wrote on 29 jun 2003 in microsoft.public.inetserver.asp.general:
I just learned that it is possible to grab a text file from another
site and display the data on my own site, however when I display the
data it does not format it correctly. Can anyone please point me in
the direction of a tutorial or help me with the code below.

John

<%
Response.Buffer = True
Dim objXMLHTTP, xml


Set xml = Server.CreateObject("Microsoft.XMLHTTP")

xml.Open "GET",
"http://iwin.nws.noaa.gov/pub/data/text/FZUS53/KCLE.TXT", False

xml.Send

Response.Write xml.responseText

Set xml = Nothing
%>

<%
Response.Buffer = True
url="http://iwin.nws.noaa.gov/pub/data/text/FZUS53/KCLE.TXT"
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET",url, False
xml.Send
t=xml.responseText
t=replace(t,vbcr&vbcr,vbcr)
Response.Write "<pre>"&t&"</pre>"
Set xml = Nothing
%>
 
R

Robb Meade

..
With this last piece you posted are you still reading from a text file
on your local server or reading from the remote url?

Hi John,

I tried it initially with my local txt file, and then changed the code back
to what you'd submitted and added the 2 lines I mentioned- this was then
using your remote file, and it spaced it all out correctly as you wanted
etc.

Robb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top