如何解析enclosure_details
属性?这是我的XML输出。
<enclosure>
<enclosure_details url="http://cdn..com/media/gallery/p18gmcacuj1o4n1572b1m1qnel1c6.jpg" length="12345" type="image/jpeg" title=<![CDATA[]]> description=<![CDATA[<p>Mergers and acquisitions have gained steam in early 2014. Here is a rundown of the whole-bank deals, shedding of noncore businesses and swapping of securities so far this year.</P><P align="right"><em>Image: Thinkstock</em></p>]]> />
<enclosure_details url="http://cdn..com/media/gallery/p18gmcacuj1527me8acrk2r7td7.jpg" length="12345" type="image/jpeg" title=<![CDATA[Carolina Domino Effect?]]> description=<![CDATA[<p>VantageSouth in Raleigh, N.C., and Yadkin Financial in Elkin, N.C., announced plans in late January for <a href="http://www..com/issues/179_18/vantagesouth-yadkin-deal-could-spur-meaningful-ma-in-north-carolina-1065227-1.html">a $300 million merger</a>. VantageSouth CEO Scott Custer will lead the bank. The MOE is expected to force other North Carolina banks to decide whether to become buyers or sellers.</P><P align="right"><em>Bloomberg News</em></p>]]> />
<enclosure_details url="http://cdn..com/media/gallery/p18gmcacuj332qvhj7c1qbucn98.jpg" length="12345" type="image/jpeg" title=<![CDATA[Cost-Cutting Focus]]> description=<![CDATA[<p>ConnectOne in Englewood, N.J., is merging with Center Bancorp in Union, N.J., in <a href="http://www..com/video/connectone-ceo-explains-banks-merger-with-center-of-nj1065072-1.html">another MOE-like deal</a> that would create a $3 billion-asset bank and is meant to produce $7 million in annual cost savings. Frank Sorrentino of ConnectOne will become the CEO.</p>]]> />
答案 0 :(得分:1)
尝试使用适用于iOS的NSXMLParser:https://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/Classes/NSXMLParser_Class/Reference/Reference.html
你在这里有一个教程:http://iphonebyradix.blogspot.com/2011/08/parsing-xml-using-nsxmlparser.html
此委托方法可以获取标记
中的字符串- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
}
此方法为您提供了包含enclosure_details
内部网址的属性- (void)parser:(NSXMLParser *)parser foundAttributeDeclarationWithName:(NSString *)attributeName forElement:(NSString *)elementName type:(NSString *)type defaultValue:(NSString *)defaultValue;