私は学校で xml の解析に取り組んでおり、Twitter の API を使用して作業しています。ツイートが投稿された日付を取得しようとしていますが、問題が発生しています。xml 内に異なる値を保持する同じ名前の 2 つの要素があります。ただし、一方は他方よりもネストされているため、論理的には、ネストされているものを確認したいと思います。どうすればそれを行うことができますか?
現在、すべてが完璧に機能しています。プロジェクトにさらに追加したいだけです。
これは、私が呼び出している didEndElement メソッドの例です。
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI: (NSString *)namespaceURI qualifiedName:(NSString *)qName
{
//Creates an instance of the singleton to grab the array stored there
DataArraySingleton *singleton = [DataArraySingleton sharedArray];
//easy access to array
NSMutableArray *array = singleton.theArray;
//If the element ends with text
if ([elementName isEqualToString:@"text"])
{
//Sets the value/key pair for text
[tweets setValue:currentXMLValue forKey:elementName];
}
//Same as above
if ([elementName isEqualToString:@"screen_name"])
{
[tweets setValue:currentXMLValue forKey:elementName];
}
//Same as above
if ([elementName isEqualToString:@"profile_image_url"])
{
[tweets setValue:currentXMLValue forKey:elementName];
}
//If the element ends with status
if ([elementName isEqualToString:@"status"])
{
//Adds the objects collected above to the array
[array addObject:tweets];
//Resets the object TweetInformation to be called again above
tweets = nil;
}
//Resets xml value
currentXMLValue = nil;
}
みんなありがとう