1
我創建在Xcode其解析XML的應用程序,但我在此解析代碼Xcode的XML解析問題
<description>
<![CDATA[
<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/Sg8z_On_Jmc?fs=1" width="580" height="25"> <param name="movie" value="http://www.youtube.com/v/Sg8z_On_Jmc?fs=1" /> <param name="allowFullScreen" value="true" /> </object>
]]>
</description>
我怎樣才能在數據或值的網址有問題?
謝謝。
我的源代碼:.M
// didStartElement在隨後開始的;
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if (![self currentStringValueTitle]) {
[self setCurrentStringValueTitle:[[NSMutableString alloc] initWithCapacity:50]];
}
if (![self currentStringValueImage]) {
[self setCurrentStringValueImage:[[NSMutableString alloc] initWithCapacity:50]];
}
if (![self currentStringValueDescription]) {
[self setCurrentStringValueDescription:[[NSMutableString alloc] initWithCapacity:50]];
}
[[self currentStringValueTitle] appendString:string];
[[self currentStringValueDescription] appendString:string];
[[self currentStringValueImage] appendString:string];
NSLog(@"Başlık: %@", [self currentStringValueTitle]);
NSLog(@"Detay: %@", [self currentStringValueDescription]);
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementName isEqualToString:@"title"]) {
[[self titleArray] addObject:[self currentStringValueTitle]];
}
if ([elementName isEqualToString:@"pubDate"]) {
[[self descriptionArray] addObject:[self currentStringValueDescription]];
}
if ([elementName isEqualToString:@"description"]) {
[[self imageArray] addObject:[self currentStringValueImage]];
}
[self setCurrentStringValueTitle:nil];
[self setCurrentStringValueDescription:nil];
[self setCurrentStringValueImage:nil];
}
感謝您的重播。我已經嘗試過,但它沒有工作,它推動所有的描述線。我編輯了我的問題並將我的源代碼。請問你能幫幫我嗎。 – 2012-04-08 18:38:26
我可以告訴你,你將需要兩個NSXMLParser實例..只需在這裏寫完整的代碼。 – 2012-04-08 18:48:50
我無法編輯原始文章,因爲它不需要更多的代碼。所以我在這個鏈接上發表了; [鏈接](https://docs.google.com/document/d/1iuGDe7fDfkB8E9AzKliqh9KirMWJWLUBiZTiVV6ML2k/編輯) 現在感謝您的幫助。 – 2012-04-08 20:06:00