Error on loadXML(URL) within P5js

var url ='*&fields=station_id,latitude,longitude,flight_category';

var airportData;

var xml;

function preload() {
 xml = loadXML(url, gotData);  //if I comment out this line it runs without error

function setup() {
  createCanvas(1280,564);  //equidistant

function gotData(xml){

Get the following error,

Uncaught TypeError: Cannot read property ‘split’ of undefined (: line 56)

loadXML is part of the core library of P5.js is it not?

Yes but read this link.
Edit : Hehe, Answered at the same time as post above.

1 Like

Yes, I saw that link before and tried copying and pasting (substituting my url for his being careful to remove the https:// as that appears to be concatenated onto the string passed in the loadXML command.), and still did not work. Still get the error on line 56.

I used the same proxy as he. Any benefit going to a different proxy. Its just an ASCII response, don’t understand why a proxy is necessary and not documented within the p5.js reference material. Did have to make changes tot he index.html file?

 * loadXML() from EkstraBladet via Proxy (v2.0)
 * Andreas_Ref & GoToLoop (2019-Feb-08)

"use strict";

const HTTP = 'https://',
      PROX = '', MODE = 'proxy/',
      SITE = '*&fields=station_id,latitude,longitude,flight_category', FOLD = 'rssfeed/', QRY = 'sport/',
      FILE = 'sport.xml',
      REMOTE = true,
      TAG = 'title',
      LIST = 'ol', ITEM = 'li',
      titles = [];

let xml;

function preload() {;
  xml = loadXML(REMOTE && LINK || FILE, print, console.warn);

function setup() {
  noCanvas(), noLoop();

  const items = xml.getChild('data').getChildren('METAR');

  for (const item of items) {


Same error

I did some experiments and I’ve found this proxy link works:*&hoursBeforeNow=1&minLat=25&minLon=-125&maxLat=50&maxLon=-66&fields=station_id,latitude,longitude,flight_category

But if we shorten KSE* to KS* it stops working:*&hoursBeforeNow=1&minLat=25&minLon=-125&maxLat=50&maxLon=-66&fields=station_id,latitude,longitude,flight_category

Much probably b/c the request above bacame too big now for the proxy server.

However w/ this other proxy server it doesn’t care much about the request’s size; even K* is OK:*&hoursBeforeNow=1&minLat=25&minLon=-125&maxLat=50&maxLon=-66&fields=station_id,latitude,longitude,flight_category

P.S.: The URL above w/ this particular proxy only works when programmatically requested.

It won’t work by clicking or pasting it in a browser!

I tried proxy and it worked for a while then it stopped working. Are they limited use proxies or something. I don’t understand still why we have to use a proxy. I can enter the url straight in a browser and it returns data.

Proxies aren’t meant for constant usage AFAIK.

The link still works on the proxy’s demo site though:*&hoursBeforeNow=1&minLat=25&minLon=-125&maxLat=50&maxLon=-66&fields=station_id,latitude,longitude,flight_category

B/c the site doesn’t enable CORS for its API service:

CORS is exclusive to browsers. A non-browser server can grab resources regardless of CORS.