Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Dominic Bryan
14,452 PointsHelp Understand XML parsing in Swift. Attempting to build a RSS reader in swift
I am trying to build a RSS reader in swift, I am running into problems with lack of knowledge of XML parsing in swift. I have a table view that shows title and pubDate but then I click the table to go to a story and have have two problems.
I am parsing the <description> tag but when looking through the XML file there is two description tags which I have worked out that the first one is a brief couple sentences and the second description tag is the main body of text. How would I get the second description tag?
When I run the app some of te text being pulled off has odd characters in like so "’". How would I get rid of this? I have a feeling it is apostrophes and such
Thanks for any help
3 Answers
Steve Hunter
57,712 PointsAh - I figured the XML was from an online source.
If you look at the Weather App in Swift on here, that will show you how to parse through JSON dictionaries etc.
Pasan Premaratne
Treehouse TeacherI currently don't have plans to do a full XML parsing course since JSON is more prevalent these days, but there are plenty of libraries you could use:
SWXMLHash: This is a pure Swift alternative. Swift libraries are relatively new and untested though so if you know how to use Objective-C code within your Swift project, here's a more battle tested library: XMLDictionary
Dominic Bryan
14,452 PointsThanks Pasan Premaratne , I'll take a look at them. I've done couple bits with objective c but not to familiar with bridging into swift
Steve Hunter
57,712 PointsCan you share the XML source and your current code? That might help us understand where you're coming from.
Thanks,
Steve.
Dominic Bryan
14,452 PointsSure Steve do you know of an easy way to do so? It consists of a couple of pages so slightly awkward.
If its to much hassle you could point me in the direction of a online source to read up on this? Would love to see a lesson or tow on this subject Pasan Premaratne
Thanks
Dominic Bryan
14,452 PointsDominic Bryan
14,452 PointsYes its rather annoying, I have taken and completed the track its just some extra details i need but thanks for taking the time Steve.
Thanks