METAR Grabber

Hello, everyone!

My weekend project; to create a working METAR grabber, that can take an XML document, such as this one from the FAA’s databases, and grab one XML element, to log it to the console.

Once this data is received, it will be implemented into a website called VATTASTIC that will read user input in the chat, and respond with a METAR. This piece of the puzzle is not the focus yet, and cannot be because I cannot access the data.

Here’s the code, and the error I’m getting:


METARBot.js:1 Uncaught SyntaxError: Unexpected identifier

I tried a version editing InnerHTML as well, with the same result:

Any help would be appreciated. Thanks.


Found something about XML Schemas that might be messing with this? Still no explanation for the JavaScript error… Ideas?

I am not familiar with what you are working with, but I noticed one really simple thing. In your getTheXml function, you have an unnecessary semicolon before the closing parentheses. Just wanted to point that out.

I’ll take a look… Thanks.

1 Like

No cigar there… Will be rewriting this with the new JSON format they released recently, something I’m more comfortable with. Thanks for the help.

1 Like

Syntax errors should be fairly trivial to fix

Also, I suggest avoiding online “try it” apps, better use local files and open that in your browser, either by serving it with some http server (for example if you have python3 installed: python -m http.server in the site directory) or directly from the file system. Sharing the source is probably most conveniently done with a git repository, though a compressed archive would get the job done in a pinch

Just copied and pasted it onto the try it apps online from my local files so I didn’t have to paste raw code here. :wink:

I suspect your browser would point out exactly where the syntax error is if you peek in its console

It did…

I just couldn’t figure out what that meant. Now I fixed it. Thanks.

After fixing that (though it’s not that line is it) - you’ll run into issues with same origin policy - I’m kind of clueless on that but it might be that the request needs to be done server-side, (unless you can coax your users into disabling that security feature in their browser, which seems unlikely)

If they have a different api, then yeah. That could get around this.

If this application of yours is supposed to run on a server (if it doesn’t need to show the data on the same page that you are using to request the xml) then it has no business running in a browser anyhow, in which case this api seems just fine

$ curl '
<?xml version="1.0" encoding="UTF-8"?>
<response xmlns:xsd="" xmlns:xsi="" version="1.2" xsi:noNamespaceSchemaLocation="">
  <data_source name="metars" />
  <request type="retrieve" />
  <errors />
  <warnings />
  <data num_results="1">
      <raw_text>PHTO 071353Z 23004KT 10SM FEW060 19/18 A2993 RMK AO2 SLP133 T01940178</raw_text>
      <sky_condition sky_cover="FEW" cloud_base_ft_agl="6000" />

Thanks for the shot… I am, however, running it locally to run a bot myself. I don’t own the website nor server, so I’ll just be running the code myself.