</CityModel>`; // XMLをパースする const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, "application/xml"); // 名前空間リゾルバ function nsResolver(prefix) { const ns = { 'gml': 'http://www.opengis.net/gml', 'bldg': 'http://www.opengis.net/citygml/building/2.0' }; return ns[prefix] || null; } // XPathを使⽤して "bldg:measuredHeight" を抽出する const heights = []; const nodesSnapshot = xmlDoc.evaluate('//bldg:measuredHeight', xmlDoc, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (let i = 0; i < nodesSnapshot.snapshotLength; i++) { heights.push(nodesSnapshot.snapshotItem(i).textContent); } console.log(heights); // ["10", "20"] こいつ👉 PLATEAUくらい情報量があると XPathの処理が爆発する