Doubt in parsing rss fields

Discussion in 'iPhone/iPad Programming' started by iphonejudy, Feb 17, 2009.

  1. macrumors 6502

    iphonejudy

    Joined:
    Sep 12, 2008
    #1
    I need to parse rss fields like
    <xml>
    <item>
    <title>title</title>
    <description>descriptionsssssssss....</description>
    <url>http:/example/example.jpg</url>
    </item>
    </xml>
    I can parse title and description,But the image url is displayed as it is.
    How can i parse the image url to display the image?
     
  2. macrumors 68040

    Joined:
    Apr 22, 2005
    #2
    It sounds like you don't have a parsing question, you have a "how do I load an image from a remote URL?" question.
     
  3. macrumors 6502

    Joined:
    Sep 17, 2003
    #3
    You should be able to load a UIWebView with the image URL.
     
  4. macrumors member

    chbeer

    Joined:
    Sep 22, 2008
    Location:
    Berlin
    #4
    You need to understand the difference between parsing and loading URLs. What you want is to load the image from the url you parsed.

    UIWebView is waaayy oversized for displaying a single image!! Use UIImageView and load the image yourself. (Don't have the documentation at hand but that is easy).
     
  5. macrumors 6502

    Joined:
    Sep 17, 2003
    #5
    You mean the component is too heavy-weight? I concur but it's a quick and easy way to do what they want. It won't scale well but perhaps that's not a problem.

    To make a UIImage from a URL you want to do something like

    Code:
    NSString *path = @"http://whateveryoururlis.com/yourimage.jpg";
    NSURL *url = [NSURL URLWithString:path];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *img = [[UIImage alloc] initWithData:data cache:NO];
    Then put that UIImage in a UIImageView.
     
  6. thread starter macrumors 6502

    iphonejudy

    Joined:
    Sep 12, 2008
    #6
    I am using the below code to display image from url

    NSString *pathimage = vController.currentUrl1;

    NSURL *urlImage= [NSURL URLWithString:pathimage];

    NSData *data = [NSData dataWithContentsOfURL:urlImage];

    UIImage *img = [[UIImage alloc] initWithData:data cache:YES];

    vController.imageview1.image=img;

    But the image is not displayed.Can anyone tell me solution?
     

Share This Page