1
このXMLが下に形成される方法は、コードがn13期間とn7期間の両方を取得しているため、結果をn13データのみに限定することができますどういうわけか?NSXMLParserを特定の要素の後の要素に制限する方法
<time-layout time-coordinate="local" summarization="12hourly">
<layout-key>k-p12h-n13-1</layout-key>
<start-valid-time period-name="This Afternoon">2016-06-30T12:00:00-04:00</start-valid-time>
<start-valid-time period-name="Tonight">2016-06-30T18:00:00-04:00</start-valid-time>
<start-valid-time period-name="Friday">2016-07-01T06:00:00-04:00</start-valid-time>
<start-valid-time period-name="Friday Night">2016-07-01T18:00:00-04:00</start-valid-time>
<start-valid-time period-name="Saturday">2016-07-02T06:00:00-04:00</start-valid-time>
<start-valid-time period-name="Saturday Night">2016-07-02T18:00:00-04:00</start-valid-time>
<start-valid-time period-name="Sunday">2016-07-03T06:00:00-04:00</start-valid-time>
<start-valid-time period-name="Sunday Night">2016-07-03T18:00:00-04:00</start-valid-time>
<start-valid-time period-name="Independence Day">2016-07-04T06:00:00-04:00</start-valid-time>
<start-valid-time period-name="Monday Night">2016-07-04T18:00:00-04:00</start-valid-time>
<start-valid-time period-name="Tuesday">2016-07-05T06:00:00-04:00</start-valid-time>
<start-valid-time period-name="Tuesday Night">2016-07-05T18:00:00-04:00</start-valid-time>
<start-valid-time period-name="Wednesday">2016-07-06T06:00:00-04:00</start-valid-time>
</time-layout>
<time-layout time-coordinate="local" summarization="12hourly">
<layout-key>k-p24h-n7-1</layout-key>
<start-valid-time period-name="This Afternoon">2016-06-30T12:00:00-04:00</start-valid-time>
<start-valid-time period-name="Friday">2016-07-01T06:00:00-04:00</start-valid-time>
<start-valid-time period-name="Saturday">2016-07-02T06:00:00-04:00</start-valid-time>
<start-valid-time period-name="Sunday">2016-07-03T06:00:00-04:00</start-valid-time>
<start-valid-time period-name="Independence Day">2016-07-04T06:00:00-04:00</start-valid-time>
<start-valid-time period-name="Tuesday">2016-07-05T06:00:00-04:00</start-valid-time>
<start-valid-time period-name="Wednesday">2016-07-06T06:00:00-04:00</start-valid-time>
</time-layout>
私DidStartElementコード:layout-key
という名前の処理要素で
if weAreInsideAnItem == true {
if (elementName as NSString).isEqualToString("start-valid-time") {
if let periodAsNSString: NSString = attributeDict["period-name"] {
guard let periodAsString: String = periodAsNSString as String else {return}
tempForecastTimes.append(periodAsString)
}
}
}
どのようにノードをループしますか? –
関連していませんが、 'if(elementName as NSString).isEqualToString(" foo "){...}'パターンは 'if elementName ==" foo "{...}'に単純化できます。 – Rob