format a retrieved text file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    format a retrieved text file

    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.CreateOb ject("Microsoft .XMLHTTP")

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

    xml.Send

    Response.Write xml.responseTex t

    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.


  • Robb Meade

    #2
    Re: format a retrieved text file

    "John" wrote ...
    [color=blue]
    > 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.[/color]

    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


    Comment

    • Robb Meade

      #3
      Re: format a retrieved text file

      "John" wrote ...

      [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...



      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


      Comment

      • Robb Meade

        #4
        Re: format a retrieved text file

        "Robb Meade" wrote ...
        [color=blue]
        > the results came out fine...[/color]

        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 :(


        Comment

        • Evertjan.

          #5
          Re: format a retrieved text file

          John wrote on 29 jun 2003 in microsoft.publi c.inetserver.as p.general:[color=blue]
          > 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.CreateOb ject("Microsoft .XMLHTTP")
          >
          > xml.Open "GET",
          > "http://iwin.nws.noaa.g ov/pub/data/text/FZUS53/KCLE.TXT", False
          >
          > xml.Send
          >
          > Response.Write xml.responseTex t
          >
          > Set xml = Nothing
          > %>
          >[/color]

          <%
          Response.Buffer = True
          url="http://iwin.nws.noaa.g ov/pub/data/text/FZUS53/KCLE.TXT"
          Set xml = Server.CreateOb ject("Microsoft .XMLHTTP")
          xml.Open "GET",url, False
          xml.Send
          t=xml.responseT ext
          t=replace(t,vbc r&vbcr,vbcr)
          Response.Write "<pre>"&t&" </pre>"
          Set xml = Nothing
          %>


          --
          Evertjan.
          The Netherlands.
          (Please change the x'es to dots in my emailaddress)

          Comment

          • Robb Meade

            #6
            Re: format a retrieved text file

            "John" wrote..
            [color=blue]
            > With this last piece you posted are you still reading from a text file
            > on your local server or reading from the remote url?[/color]

            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


            Comment

            Working...