0

How do I parse enclosure_details attributes? Here is my XML output.

<enclosure>
 <enclosure_details url="http://cdn..com/media/gallery/p18gmcacuj1o4n1572b1m1qnel1c6.jpg" length="12345" type="image/jpeg" title=<![CDATA[]]> description=<![CDATA[&lt;p&gt;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.&lt;/P&gt;&lt;P align=&quot;right&quot;&gt;&lt;em&gt;Image: Thinkstock&lt;/em&gt;&lt;/p&gt;]]> />
 <enclosure_details url="http://cdn..com/media/gallery/p18gmcacuj1527me8acrk2r7td7.jpg" length="12345" type="image/jpeg" title=<![CDATA[Carolina Domino Effect?]]> description=<![CDATA[&lt;p&gt;VantageSouth in Raleigh, N.C., and Yadkin Financial in Elkin, N.C., announced plans in late January for &lt;a href=&quot;http://www..com/issues/179_18/vantagesouth-yadkin-deal-could-spur-meaningful-ma-in-north-carolina-1065227-1.html&quot;&gt;a 300ドル million merger&lt;/a&gt;. 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.&lt;/P&gt;&lt;P align=&quot;right&quot;&gt;&lt;em&gt;Bloomberg News&lt;/em&gt;&lt;/p&gt;]]> />
 <enclosure_details url="http://cdn..com/media/gallery/p18gmcacuj332qvhj7c1qbucn98.jpg" length="12345" type="image/jpeg" title=<![CDATA[Cost-Cutting Focus]]> description=<![CDATA[&lt;p&gt;ConnectOne in Englewood, N.J., is merging with Center Bancorp in Union, N.J., in &lt;a href=&quot;http://www..com/video/connectone-ceo-explains-banks-merger-with-center-of-nj1065072-1.html&quot;&gt;another MOE-like deal&lt;/a&gt; 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.&lt;/p&gt;]]> />
Mick MacCallum
130k40 gold badges283 silver badges284 bronze badges
asked Feb 20, 2014 at 12:41

1 Answer 1

1

Try NSXMLParser for iOS: https://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/Classes/NSXMLParser_Class/Reference/Reference.html

And you have a tutorial here: http://iphonebyradix.blogspot.com/2011/08/parsing-xml-using-nsxmlparser.html

This delegate method get you the string inside the tag

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
}

This method gets you the attribute in your case the url inside enclosure_details

- (void)parser:(NSXMLParser *)parser foundAttributeDeclarationWithName:(NSString *)attributeName forElement:(NSString *)elementName type:(NSString *)type defaultValue:(NSString *)defaultValue;
answered Feb 20, 2014 at 12:44
Sign up to request clarification or add additional context in comments.

6 Comments

i have implement same Parser, but when i get this data, i dont know how to access.. <enclosure> <enclosure_details url="cdn..com/media/gallery/p18gmcacuj1o4n1572b1m1qnel1c6.jpg" length="12345" type="image/jpeg" title=<![CDATA[]]> description=<![CDATA[&lt;p&gt;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.&lt;/P&gt;&lt;P align=&quot;right&quot;&gt;&lt;em&gt;Image: Thinkstock&lt;/em&gt;&lt;/p&gt;]]> />
NSXMLParser has a delegate methods, and it will return you the value of this tag. please follow the link
yes sir, same i use both links for parsing, but i cant have this idea, how to implement ? I want to access all content of <enclosure_details> but i have no idea, how to do? Here is my code, if ([elementName isEqualToString:@"enclosure"]) { NSString * name = [attributeDict valueForKey:@"enclosure_details"]; [item setObject:name forKey:@"articleEnclosure"]; }
i never use XML parser, so i have no idea. can you give me some demo code ?
mostly i am using JSON parsing, and XML parsing too.. but in XML parsing i never do like that issue.. anyone suggest me ?
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.