const https = require('https');

const url = "https://www.wms.nrw.de/umwelt/erneuerbare_energien_nrw?SERVICE=WMS&REQUEST=GetCapabilities";

https.get(url, (res) => {
    let data = '';
    res.on('data', chunk => data += chunk);
    res.on('end', () => {
        console.log("--- Caps for erneuerbare_energien_nrw ---");
        const names = [];
        const titles = [];
        let m;

        // Simple regex - might miss nested structure but gets list
        const nameRe = /<Name>(.*?)<\/Name>/g;
        while ((m = nameRe.exec(data)) !== null) names.push(m[1]);

        const titleRe = /<Title>(.*?)<\/Title>/g;
        while ((m = titleRe.exec(data)) !== null) titles.push(m[1]);

        console.log("Names:", names);
        console.log("Titles:", titles);
    });
}).on('error', e => console.log(e.message));
