mwaterfall / mwfeedparser Goto Github PK
View Code? Open in Web Editor NEWAn Objective-C RSS / Atom Feed Parser for iOS
License: Other
An Objective-C RSS / Atom Feed Parser for iOS
License: Other
Hello,
I've got a feed containing CDATA in the content:encoded
I've got an error each time the parser goes through those CDATA. Here's the URL of the feed : http://www.saintgermainenlaye.fr/no_cache/?type=101
Thanks!
Hi!
I'm using in a project your NSString+XMLEntities class but I'm having trouble in some conversions. For instance this text block (first line is before and second is after):
"de tamaños variados, que permitirán diseñar los distintos itinerarios."
"de tamaÑos variados, que permitirÁn diseÑar los distintos itinerarios."
It's converting the codes to the upper case version of that letter. It should be:
"de tamaños variados, que permitirán diseñar los distintos itinerarios."
Any Idea why? Thank you!
I haven't traced back exactly to where it's not being parsed, but when I'm parsing a feed (http://www.cambriancollege.ca/NewsEvents/_layouts/listfeed.aspx?List=50addb35-da99-4807-8549-138769f0fd0d)
all of the feed item URLs that get cut apart are due to them containing an ID=### at the end
(like so, http://www.cambriancollege.ca/NewsEvents/Lists/News%20Features%20%20Media%20Releases/Display.aspx?List=50ADDB35-DA99-4807-8549-138769F0FD0D&ID=896)
I have noticed a performance bottleneck. When parsing a large RSS feed such as the itunes 300 new releases () it can spend 60% of the total parsing time in [NSString stringByRemovingNewLinesAndWhitespace].
The entire parsing operation (not including downloading of data from the server) can take 3900ms, and roughly 2200ms of that can be in stringByRemovingNewLinesAndWhitespace.
These figures where taken when testing on a release build on an iPhone 3GS using the MWFeedParser sample code and the following RSS feed:
[Note: is this stripping of white space needed? Could it be made an optional feature to save CPU time?]
When an atom feed item has content but no summary, the content is moved to the summary property of MWFeedItem. According to http://www.ietf.org/rfc/rfc4287, it's perfectly legal for an item to have content and no summary. Moving the content to the summary property can cause confusion.
A better solution may be to just leave the summary empty and keep the content in the Content property of MWFeedItem.
If a url in my summary is then disappears the part of the URL after the /.
For example:
twitter.com/username
become
twitter.com
Is there a solution for this?
I dont want to download all the articles of the feed. The file is too big. I just want to download the 1st 10 and if the user wants more he can click on "Load more" and it will download more.
Hello, i'm using your classes to remove my html tags from an NSString. Its working fine. But, its removing my letter 2 particularly alone. I don't know why its happend? Please find my records below
ออกอากาศวันที่ 2 เมษายน 2556
\u0e2d\u0e2d\u0e01\u0e2d\u0e32\u0e01\u0e32\u0e28\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48 2 \u0e40\u0e21\u0e29\u0e32\u0e22\u0e19 2556
&
\r\n\tCheeze FM 107.4 Today's hot music คลื่นวิทยุเพลงฮิตในจังสระบุรี คลื่นนี้มีแต่เพลงฮิตติดCheezeeee\r\n
When i try to replace this using stringByConvertingHTMLToPlainText like below
NSString *shortD = [[[webServiceRecords objectAtIndex:indexPath.row] objectForKey:@"shortDesc"] stringByConvertingHTMLToPlainText];
Result - "Cheeze FM 07.4 Today's hot music คลื่นวิทยุเพลงฮิตในจังสระบุรี คลื่นนี้มีแต่เพลงฮิตติดCheezeeee" // 1 is missing
Its removing some numeric letters always. What may be the reason? And, how do i fix this?
My files - https://dl.dropboxusercontent.com/u/69670844/Nsstring%2BHTML.zip
Hi,
i want to read url and name inside test tag (i think its called attribute ).
how can i read this? i know that i need to edit MWFeedParser.m but i dont know how..
thanks
22diabolo
Hello!
I was just wondering if you could implement caching, or give out a few hints on how to approach it, because I'm having trouble getting it to work... I attempted to implement caching the parsedItems, using the EGOCache (https://github.com/enormego/EGOCache) classes but to no avail... thanks in advance!
The code
NSString *processedText = [currentText stringByRemovingNewLinesAndWhitespace];
in MWFeedParser.m (line 611) seems to remove required chars.
I had problem with some urls in item link similar to
http://www.myfeed.com/node/1062190
The url was changed in
http://www.myfeed.com/node/ 62 90
(with whitespace)
When I use this link
http://vnexpress.net/rss/gl/xa-hoi.rss
I receive an error
MWFeedParser[1888:207] Finished Parsing With Error: Error Domain=MWFeedParser Code=2 "cannot decode raw data" UserInfo=0x4d59880 {NSLocalizedDescription=cannot decode raw data}
I tried another link
http://www.salon.com/rss/all_salon.rss
and it worked.
Hey Waterfall,
Now the app / framework means that the application is always open in iOS4... Any plans to add a refresh button in there to re gather the data?
Thanks
Dan
I realize that "NSString+XMLEntities" is depreciated (replaced by "NSString+HTML").
However, "NSString+HTML" stringByEncodingHTMLEntities is not suitable for encoding entities for use in XML. The reason is that XML apparently only permits these 5 keyword mapped entities:
{ @""", 34 },
{ @"&", 38 },
{ @"'", 39 },
{ @"<", 60 },
{ @">", 62 },
For XML, all other entities must apparently be mapped to the appropriate &#xxx; value. Example character: Ø. The Ø needs to instead be Ø or other XML parsers barf.
Do you know of a quick workaround? Thanks!
Hi,
Just wondering if you had any ideas...
Basically, I'm parsing the item.content into a textfield (to give me complete control over the formatting of the text) and it works really well.
The only issue is that when I convert html to plain text, I lose the
tags and so there are no newlines. It appears that the feeds I am parsing do not use
tags!
I just wondered if you (or anybody else) had found a way to detect new paragraphs in the html and then keep them when the html is converted into plain text!
Many thanks in advance!
I want do mod this file to do something else. In GTMNSString+HTML.h I add this code:
(NSString *)getFirstImage;
in GTMNSString+HTML.m I add the implementation:
(NSString *)getFirstImage {
//Do something
return url;
}
}
I use this with this code:
NSString *url = [item.summary getFirstImage];
But I received this warning,
422:21:{422:21-422:49}: warning: instance method '-getFirstImage' not found (return type defaults to 'id') [3]
Also in MWFeedItem.h I added
NSString *image;
@Property (nonatomic, copy) NSString *image;
And than in the implementation I added the @synthesize image; but when I try to use it with
MWFeedItem *item =[reader.feedItems objectAtIndex:index];
item.image
i can't use it! why this?
I've got an application where I'd like to have the ability to view the RSS feed content offline but as I look into how the feed URL is pulled in, basically all caching capabilities specified by the client are wiped out.
The following definition ought not to be the default, in my opinion but should be left at the default cache policy NSURLRequestUseProtocolCachePolicy
from here.
Option 1
Utilize an additional init parameter to send in the NSURLRequestCachePolicy
value.
Option 2
Or possibly the NSURLRequest ought to just come in on the init method so that more of the request can be modified and the init would accept an NSMutableRequest
instead of just an NSRequest
.
Current Code in MWFeedParser.m
// Request
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:60];
For some background on the iOS caching dilemma you might check out this article - http://blackpixel.com/blog/2012/05/caching-and-nsurlconnection.html
If either of these options sounds good, I'll go ahead and implement either one, probably Option 2 ultimately for ongoing flexibility.
I try to implement your great FeeedParser into my Project. I only use ViewController because of my special design. So my question is: how can I use the MWFeedParser without a RootViewController? I looks possible to do all the stuff in a normal tableView but i can't get it.
Best Regards
cutischmidt
Wondering if there's anyway of caching the info from the feed. Thanks to iOS 4.0 it stays there for a bit, but disappears after a bit.
Hello,
I noticed in the README that you mentioned that the parser is not thread-safe. I'm guessing this means that two threads can't access the same parser instance at the same time. My question: do you think its safe to have two parallel threads each with their own instance of the parser working simultaneously? Or would this also not be thread-safe?
Thanks again and especially for such a great open-sourced component.
I am trying to decode html entities from a string using your NSString+HTML category. GTMNSString+HTML is also imported.
I am using Xcode 4.3.2 with ios 5.1
Can you help?
-[__NSCFString stringByDecodingHTMLEntities]: unrecognized selector sent to instance 0x6e65a40
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString stringByDecodingHTMLEntities]: unrecognized selector sent to instance 0x6e65a40'
Hello, there seems to be a memory leak in the parser:
MWFeedParser.m
line 330:
self.item = [[MWFeedItem alloc] init];
should be:
self.item = [[[MWFeedItem alloc] init] autorelease];
because both "alloc" and the "item" property (which has auto retain) retain the object...
in the end, it doesn't get freed with the single release in dealloc (or so it seems).
Thanks
I've been trying to extend the summary description on the parser so that it will include the entire article. Do you guys have any suggestions as to how to do this?
Thanks!
Hi, I replaced the RSS link to http://www.ynet.co.il/Integration/StoryRss2.xml
And then instead of hebrew i got Gibbrish.
10x in advanced
Benny
Hi,
Is there a way to parse directly NSData? I need to implement my download methods and use MWFeedParser only as a parser.
HI, I find some rss feed, e.g. http://noc.leaseweb.com/rss/maintenance.php They mark the time stamp in the description. I really have no idea how to fix that, cause I try to save the articles into database and show them again. If there is not correct time stamp, it is really hard to order them or decided which articles I have saved when user refresh the feed. I know guid is a way, but sounds also complex, how do you think about that?
Btw. Good job, thx for the codes. My project is not yet release, when it release, I will note you.
Hello,
I had issues with some specific text encoding when the http headers were not indicating the text encoding (like this one for example : http://www.torrentrg.com/bbs/rss.php?bo_table=torrent_variety ).
To fix this, I decided to get the encoding type from the XML declaration if we don't get it from http headers :
<?xml version="1.0" encoding="euc-kr"?>
If you want to check about this, here is my code ... in MWFeedParser.m / - (void)startParsingData:(NSData *)data textEncodingName:(NSString *)textEncodingName :
[...]
// Not UTF-8 so convert
MWLog(@"MWFeedParser: XML document was not UTF-8 so we're converting it");
NSString *string = nil;
// Attempt to detect encoding from response header
NSStringEncoding nsEncoding = 0;
[...]
becomes :
[...]
// Not UTF-8 so convert
MWLog(@"MWFeedParser: XML document was not UTF-8 so we're converting it");
NSString *string = nil;
// If no text encoding indication was in the response header
// then try to get encoding from the XML declaration
if (textEncodingName == nil) {
NSData* xmlEncodingData = [NSData dataWithBytesNoCopy:(void *)[data bytes]
length:100
freeWhenDone:NO];
NSString* xmlEncodingString = [[NSString alloc] initWithData:xmlEncodingData encoding:NSUTF8StringEncoding];
if (!xmlEncodingString) xmlEncodingString = [[NSString alloc] initWithData:xmlEncodingData encoding:NSISOLatin1StringEncoding];
if (!xmlEncodingString) xmlEncodingString = [[NSString alloc] initWithData:xmlEncodingData encoding:NSMacOSRomanStringEncoding];
if ([xmlEncodingString hasPrefix:@"<?xml"]) {
NSRange a = [xmlEncodingString rangeOfString:@"?>"];
if (a.location != NSNotFound) {
NSString *xmlDec = [xmlEncodingString substringToIndex:a.location];
NSRange b = [xmlDec rangeOfString:@"encoding=\""];
if (b.location != NSNotFound) {
NSUInteger s = b.location+b.length;
NSRange c = [xmlDec rangeOfString:@"\"" options:0 range:NSMakeRange(s, [xmlDec length] - s)];
if (c.location != NSNotFound) {
textEncodingName = [xmlEncodingString substringWithRange:NSMakeRange(b.location+b.length,c.location-b.location-b.length)];
}
}
}
}
[xmlEncodingString release];
}
// Attempt to detect encoding from response header or XML declaration
NSStringEncoding nsEncoding = 0;
[...]
Hi,
This isn't really an issue - more of a plea for help! I apologise if it's in the wrong section, I'm really new to this.
Basically, I was wondering how to add a "Refresh" button and whether or not it is possible to include images from the feeds?
Any help would be greatly appreciated!
this function is available in google reader but not in MWFeedParser. Currently its limited to 10
Is there a way to do it?
Error Domain=MWFeedParser Code=3 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 9.)" UserInfo=0x7468430 {NSLocalizedDescription=The operation couldn’t be completed. (NSXMLParserErrorDomain error 9.)}
I got above debug error, when I parse the feed:
http://www.facebook.com/feeds/notes.php?id=9445547199&viewer=0&key=f4913b0647&format=rss20
I'm trying to find the reason.
clang: error: no such file or directory: '/Users/unicondor/Library/Developer/Xcode/DerivedData/DingUnisannio-czbgknwdwtdvjzfalsaqpvwuqqul/Build/Products/Debug-iphoneos/libMWFeedParser.a'
Only when i try to compile my project on my device... If i run it on the simulator, he work fine...
I've found that some feeds are not parsed correctly !
This one for example : http://extratorrent.com/rss.xml?type=popular
After investigation, it seems to fail because of the category tag sometimes contains the "& nbsp;" string ("Movie& nbsp;/& nbsp;Action").
According to Instruments, there are memory leaks here,
Within - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
(around line 608)
// Remove newlines and whitespace from currentText
NSString *processedText = [currentText stringByRemovingNewLinesAndWhitespace];
(around line 622)
else if ([currentPath isEqualToString:@"/rss/channel/item/pubDate"]) { if (processedText.length > 0) item.date = [NSDate dateFromInternetDateTimeString:processedText formatHint:DateFormatHintRFC822]; processed = YES; }
(around line 692)
// Dispatch item to delegate
[self dispatchFeedItemToDelegate];
I've been trying to understand them but no luck so far.
Hey @mwaterfall,
noticed this bit of code doesn't use the data argument anywhere in the string or format being appended.
Should it just be pulled out? or is there something else that is to be accomplished?
if (ELEMENT_IS_EMPTY(elementName)) {
[currentText appendFormat:@" />", elementName];
} else {
[currentText appendFormat:@">", elementName];
}
NSDateFormatter
is not threadsafe.
This causes MWFeedParser to crash when parsing dozens of feeds in parallel.
Adding
@synchronized(dateFormatter) {
…
}
to both, dateFromRFC822String:
and dateFromRFC3339String:
fixed it.
But then again a static NSDateFormatter was probably chosen to be used in order to improve performance, which the @synchronized(){…}
locks kind of destroy. Using non-static temporary NSDateFormatter instances would probably be a better choice.
Hi! Thanks for your project!
I love it and i use it in my app. Now I need to add one class attribute in MWFeedItem. But when I create an object of this type, I can't access to the attribute that I create before. I can't understand why!
Can you help me? Thanks
sorry. didn't read past issue reports. I'll try to fork the project to try to get the media extensions from flickr.
Is it possible to get the first image of the article?
Hi,
I'm trying to use the NSString+HTML category and sometimes I see the string is being parse using escapeSequence
instead of uchar
value (i.e. " instead of "). Is there any reason for this?
I'm asking because the library I'm using (Three20) does not work with the string parsed by escapeSequence
value but it works great with uchar
value.
Thanks
Can I edit the code somewhere to return old news instead? That way user can read it with no internet connection.
Hej,
Any plans to add the parsing of the guid / id tag in MWFeedParser?
Oli
I happened to be getting started with this while offline, and found that file:// urls weren't supported. If you are interested in adding that, here is what I changed around line 161 in MWFeedParser.m. (Note this only works for synchronous connections).
NSData *data;
NSError *error = nil;
if ([@"file" isEqualToString:[[NSURL URLWithString:url] scheme]]) {
NSString *xml = [NSString stringWithContentsOfURL:[NSURL URLWithString:url] encoding:NSUTF8StringEncoding error:nil];
data = [xml dataUsingEncoding:NSUTF8StringEncoding];
} else {
NSURLResponse *response = nil;
data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
}
if (data && !error) {
[self startParsingData:data]; // Process
} else {
[self failWithErrorCode:MWErrorCodeConnectionFailed description:[NSString stringWithFormat:@"Synchronous connection failed to URL: %@", url]];
success = NO;
}
clang: error: no such file or directory: '/Users/unicondor/Library/Developer/Xcode/DerivedData/DingUnisannio-czbgknwdwtdvjzfalsaqpvwuqqul/Build/Products/Debug-iphoneos/libMWFeedParser.a'
Only when i try to compile my project on my device... If i run it on the simulator, he work fine...
Hi
I have an situation where I need to stop parsing and then start parsing again immediately. I will get an error saying: "Cannot start parsing as parsing is already in progress".
It seems that even though you are calling the [delegate feedParserDidFinish] you forget to call [self parsingFinished]. This could be due to some async issues I cannot see.
Please advice,
Martin Lobger
Hi, please is here anybody, who can give me a code with tutorial how can I add images to my rss feed? Tanks a lot!
Steve
Hello,
the category "NSDate+InternetDateTime" seems to missing from the latest commit (f2bb31c)
whenever the parser starts parsing, i can scroll my scrollview, seem that it is blocking the main thread. While i keep scrolling before parsing, the parser will no parse until i stop scrolling. Is there anyway to parse the feed in a background thread so it doesn't block the main ui thread?
Hi,
I cannot even begin to thank you for all the help your code has given me! I've extracted the URL of images and displayed them in the tableview, put them in a fancy detail view and I'm really pleased with the result!
The final element I'm having issues with is getting the URL of enclosures such as a podcast.
I know you don't have time to help in detail with individual issues but I was hoping you could just explain how I can extract it!
Many thanks in advance!
Hi,
one of my html string has ° which is equal to degree symbol. But it give me infinite symbol.
even   returns me crucifix signs
Hi,
first of all I would give you my best congratulations for this project...it works great!! :)
I'm writing because I would like to implement a Yahoo Media RSS parsing: because I'm a very newbie of Objective-C in general, my question is what is/are the method(s) that I have to modify (or implement from scratch) for this purpose and if you can write some lines of codes as example!
Thank you very much in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.