format a retrieved text file

Discussion in 'ASP General' started by Robb Meade, Jun 29, 2003.

  1. Robb Meade

    Robb Meade Guest

    ...
    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
     
    Robb Meade, Jun 29, 2003
    #1
    1. Advertisements

  2. Robb Meade

    Robb Meade Guest

    ...

    [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
     
    Robb Meade, Jun 29, 2003
    #2
    1. Advertisements

  3. Robb Meade

    John Guest

    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.
     
    John, Jun 29, 2003
    #3
  4. Robb Meade

    Robb Meade Guest

    ...
    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 :(
     
    Robb Meade, Jun 29, 2003
    #4
  5. Robb Meade

    Evertjan. Guest

    John wrote on 29 jun 2003 in microsoft.public.inetserver.asp.general:
    <%
    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
    %>
     
    Evertjan., Jun 29, 2003
    #5
  6. Robb Meade

    Robb Meade Guest

    ..
    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
     
    Robb Meade, Jun 29, 2003
    #6
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.