RSS フィードからすべての情報を収集し、必要な情報を取り出す次のコードがあります。
$(xml).find('item').each(function() {
var stage = $(this).attr('p4:stage');
var title = $(this).find('title').text();
var desc = $(this).find('description').text();
var location = $(this).find('category').eq[0];
var billtype = $(this).find('category').eq[1];
var linkurl = $(this).find('link').text();
var thedate = $(this).find('a10\\:updated,updated').text();
thedate = thedate.substring(0,10);
info.push({'stage': stage},{'title': title},{'description': desc},{'location': location},{'billtype': billtype},{'linkurl': linkurl},{'thedate':thedate});
});
console.log(info);
しかし、送信されているものを見ると、それぞれの子が を表す 5 つの子を持つ<item>....contents.....</item>
1 つのオブジェクトではなく、200 を超える子を持つ 1 つのオブジェクトで、それぞれに の一部が含まれています。たとえば、次の<item></item>
ようになります。
[0 … 99]
0: Object
stage: "Committee stage"
__proto__: Object
1: Object
title: "Mesothelioma"
__proto__: Object
2: Object
description: "A Bill to establish a diffuse mesothelioma payments scheme and make related provision, and to make provision about the resolution of certain insurance disputes."
__proto__: Object
誰かがコードを手伝ってくれますか?
前もって感謝します