我正在 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>
如何获取数据或值中的 URL?
谢谢。
我的源代码:.M
//didStartElement 在开头 then;
- (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];
}