nmdias / FeedKit

An RSS, Atom and JSON Feed parser written in Swift
MIT License
1.19k stars 174 forks source link

Custom Attributes + CDATA Encoding #63

Closed ts-co closed 6 years ago

ts-co commented 6 years ago

I apologize if this question is easily solvable,

In my XML document I have a custom attribute (which specifies the author) that is also encoded in CDATA. I was wondering how I would use FeedKit with custom attributes and when they're encoded in CDATA.

nmdias commented 6 years ago

Hi @Pilot1000,

Have you tried parsing the feed? dc:creator is an elements of the Dublin Core namespace so FeedKit should handle it fine, even if it's inside a CDATA block.

Have a look at this section of the README file. Both the channel and channel's items have a dublinCore property.

Cheers

ts-co commented 6 years ago

I didn't understand what Dublin Core was so I didn't even think of checking what was inside it in the first place. It works now, thank you for an amazing pod!

ts-co commented 6 years ago

Before this is closed, I have a similar issue with itunesImage. It seems you can't convert it to a string or anything other than ItunesImage. Not sure how you'd use that for images. (In my instance I just need the url as a string).

nmdias commented 6 years ago

I'm not sure I understand. But if you only need is the url as a string, then the iTunes namespace should give you that. Have a look at the unit tests for the iTunes Namespace here.

feed?.iTunes?.iTunesImage?.attributes?.href
ts-co commented 6 years ago

That's exactly what I needed. Thank you!