Code Monkey home page Code Monkey logo

mwfeedparser's People

Contributors

mwaterfall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mwfeedparser's Issues

Problem converting some HTML codes

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!

Parser spends a lot of time in [NSString stringByRemovingNewLinesAndWhitespace]

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:

http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/newreleases/limit=300/rss.xml

[Note: is this stripping of white space needed? Could it be made an optional feature to save CPU time?]

Feed item content is moved to summary

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.

Summary with url with /

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?

Is it possible to get 1st 10 articles of a feed?

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.

This class removing my numeric letters from the webservice records

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

Parsed

ออกอากาศวันที่ 2 เมษายน 2556

Raw

\u0e2d\u0e2d\u0e01\u0e2d\u0e32\u0e01\u0e32\u0e28\u0e27\u0e31\u0e19\u0e17\u0e35\u0e48 2 \u0e40\u0e21\u0e29\u0e32\u0e22\u0e19 2556

&

My String

\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

Caching

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!

Hey!

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

stringByEncodingXMLEntities returns wrong values

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 &Oslash needs to instead be &#216 or other XML parsers barf.

Do you know of a quick workaround? Thanks!

NSString+HTML <p> tag issue

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!

GTMNSString+HTML I can't add class method!!

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?

NSMutableRequest cache policy seems overly restrictive.

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.

Is there a way to work without a RootViewController?

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

Caching?

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.

Quick not thread-safe question?

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.

problem using NSString+HTML

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'

Memory leak in parser

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

Lengthened Summary

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!

Parse NSData

Hi,
Is there a way to parse directly NSData? I need to implement my download methods and use MWFeedParser only as a parser.

Some RSS feed without pubDate or even without updated.

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.

Incorrect text encoding with feeds containing "euc-kr" text encoding

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;
        [...]

Images

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!

Memory leaks in FeedParser didEndElement

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.

data argument not used by format string

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];
}

Thread-unsafety in NSDate+InternetDateTime.m

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.

Add class attribute to MWFeedItem

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

flickr media tags

sorry. didn't read past issue reports. I'll try to fork the project to try to get the media extensions from flickr.

[NSString+HTML] Parse to uchar value rather than escapeSequence

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

Parsing of guid/id?

Hej,

Any plans to add the parsing of the guid / id tag in MWFeedParser?

Oli

Parse file:// urls

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;
    }

xCode 4.5 and iOS6 - no suck file or directory libMWFeedParser.a

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...

stopParsing -> parse -> error

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

Images in feed HELP please :-)

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

Parsing Block main thread

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?

Podcast Isse

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!

wrong conversion of html tag

Hi,

one of my html string has &#176 which is equal to degree symbol. But it give me infinite symbol.
even &#160 returns me crucifix signs

Parsing Media RSS

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.