Transforming METAR xml to html

classic Classic list List threaded Threaded
5 messages Options
Darren Darren
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Transforming METAR xml to html

Hi I have been using NOAA weather data on my website and I appreciate how easy it is to access and display METARs/TAFs and weather charts.

I would like to transform the following xml file, as an example, to display in html and I am a little lost.

http://weather.aero/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&stationString=cyeg,cyhz,cylw,cyxx&mostRecentForEachStation=constraint&hoursBeforeNow=12&fields=station_id,flight_category,raw_text

Any suggestions on how to do it? I can find my way around an html file but this transformation stuff is a bit foreign to me. Many thanks on any assistance you can offer. Darren



ADDS Admin ADDS Admin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Transforming METAR xml to html

Hi Darren,

There are many different ways in which the XML data could be transformed into HTML.  Which way you choose depends on many factors - such as your application needs, your development skill-set, your website hosting setup/plan, what client side (JavaScript) or server-side (PHP, Ruby, etc) languages you have available, etc.

Unfortunately, we do not have the resources to assist individuals with this level of technical development.  The good news is that there is an abundance of information out there regarding working with XML and HTML. I am afraid that the best that I can recommend at this time would be to Google around a bit, find a good book on the subject, or hire a  professional web developer.  

Best of luck to you, and thank you for supporting ADDS.
Darren Darren
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Transforming METAR xml to html

The website is more of a hobby in which I am trying to learn coding. I also use it prior to going to the airport to get a general idea what kind of weather I will face at work.

I've been looking at the examples of xml code at http://www.w3schools.com/xml/default.asp and there are many ways to do this. I enjoy learning how to code but this is more complex than html.

I'm limited by blogspot.com so the transformation code cannot reside as a separate file on the blogspot server. I can put the file on a separate server if needed.

I think the section "Transforming XML with XSLT on the Server" will meet this need....

<%
'Load XML
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("do I put the NOAA query address here?"))

'Load XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath("can I insert the xsl code for each webpage here?"))

'Transform file
Response.Write(xml.transformNode(xsl))
%>

Writing the xsl file looks pretty straight forward, if I can get past figuring out how to get the xml file information to the webpage and xsl file.

Any hints?

This is what I'd like to achieve:

<table border=1>
  <tbody>
   
    <tr>
      <th>Station ID</th>
      <th>METAR</th>
    </tr>
    <tr>
      <td>CYVR</td>
      <td>021600Z 10004KT 20SM SKC M05/M06 A3026 RMK SLP246</td>
    </tr>
    <tr>
      <td>YSSY</td>
      <td>021600Z 18019KT 9999 SCT013 BKN018 20/17 Q1013 TEMPO 1630/1900 6000 -SHRA FEW008 BKN010</td>
    </tr>
    <tr>
      <td>VHHH</td>
      <td>021600Z 02011KT 9000 FEW022 SCT028 15/07 Q1020 NOSIG</td>
    </tr>
  </tbody>
</table>

ADDS Admin ADDS Admin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Transforming METAR xml to html

Correct me if I am mistaken, but I don't believe that blogger.com templates allow any sort of server-side scripting.  The example that you show is written in Microsoft ASP, which runs on the server side.  

If your host does not allow server-side scripting, then I am afraid that you would be limited to JavaScript, which runs on the client side.  However, it could be difficult to import XML from another website with JavaScript alone because it would violate the Same Origin Policy (SOP).  There are some ways to circumvent this issue, such as JSONP or CORS, but the Text Data Server does not currently support either.  (We are however planning on investigating these options soon.)

http://en.wikipedia.org/wiki/Same_origin_policy
http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing
http://en.wikipedia.org/wiki/JSONP

Alternatively, if your blog were hosted on a system that allowed server-side scripting, then you would be able to use some of those methods described on w3schools.com (language dependent of course).

Regards,
Brent
Darren Darren
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Transforming METAR xml to html

Thanks for the links Brent.

You're right I can't upload an individual file into blogger. And it looks like the SOP means I cant store the file elsewhere for use on blogger. Too bad although I can understand the reasons why now.

I've pulled the NOAA metar.txt files and displayed them in this kml file for GoogleEarth.

Aviation Weather Layer for Google Earth

That should work in on the website too although I was hoping for more content control that the xml file would provide.

Loading...