Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7164935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:09:27+00:00 2026-05-28T14:09:27+00:00

(tl;dr: see summary at the bottom.) I am implementing an application that pulls content

  • 0

(tl;dr: see summary at the bottom.)

I am implementing an application that pulls content from an RSS feed off a single site. Here is a sample of the XML:

<item>
<title>Title</title>
<link>http://example.com</link>
<comments>http://example.com/#comments</comments>
<pubDate>Thu, 26 Jan 2012 03:05:11 +0000</pubDate>
<dc:creator>Billy D. Author</dc:creator> 
<category><![CDATA[sample_category]]></category>

<guid isPermaLink="false">http://example.com</guid>
<description><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ac erat nec odio cursus accumsan. Nam feugiat hendrerit neque, nec tristique nisl ullamcorper vel. Nullam pellentesque augue metus. Vestibulum in lectus orci, eget ornare felis.&#8230;]]></description>
<content:encoded><![CDATA[<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ac erat nec odio cursus accumsan. Nam feugiat hendrerit neque, nec tristique nisl ullamcorper vel. Nullam pellentesque augue metus. Vestibulum in lectus orci, eget ornare felis. Vestibulum nisl lacus, faucibus ac aliquet eu, pellentesque rutrum justo. Nulla fringilla venenatis augue a laoreet. Maecenas metus leo, euismod eget rutrum in, mattis eget nisi. Proin at massa sit amet odio tempor venenatis sit amet sit amet erat. Mauris vitae bibendum arcu. Curabitur a purus vitae ipsum ultricies luctus vel et velit.</p><p>Donec in lacus sit amet mi sagittis auctor eget nec nunc. Pellentesque adipiscing venenatis risus, a faucibus sem pretium quis. Nam fringilla metus eu nulla pellentesque semper. Quisque in lectus nisi. Fusce pretium accumsan purus nec sodales. Donec velit nisi, ullamcorper at faucibus vitae, lacinia quis dui. Duis eu dui leo, eget varius diam. Aliquam imperdiet volutpat tellus quis venenatis. Vivamus laoreet malesuada tincidunt. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris ut purus est. Sed quis mauris ut dolor dapibus vestibulum ut eu dolor. Cras interdum sagittis faucibus. Nulla tortor ligula, molestie at sollicitudin at, hendrerit et lacus. Nunc lorem enim, aliquet id porttitor ultrices, sodales ac sapien.</p>]]></content:encoded>
<wfw:commentRss>http://example.com/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
<enclosure url="http://example.com/some/other/stuff/>
</item>

I am interested in the following elements: title, link, pubDate, dc:creator, description, content:encoded.

As you might guess, title, link, pubDate and description pull just fine. But instead of any of the content of dc:creator I get that of pubDate, and instead of content:encoded, I get description.

For my parser object, I have

[xmlParser setDelegate:self];

[xmlParser setShouldProcessNamespaces: YES];
[xmlParser setShouldReportNamespacePrefixes:YES];
[xmlParser setShouldResolveExternalEntities:YES];

and have implemented the following methods:

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {

    // NSLog(@"element %@, ns %@, qn %@", elementName, namespaceURI, qName);

    if ( [elementName isEqualToString:@"rss"] ) {
    return;
}

if ( [elementName isEqualToString:@"channel"] ) {
    // begin the set of entries
    if (!allEntries)
        allEntries = [NSMutableArray array];
    return;
}

if ( [elementName isEqualToString:@"item"] ) {
    // item means a new post!
    // currentPost = [[DIDSEntry alloc] init]; 
    return;
}

if ( [elementName isEqualToString:@"title"]) {
    [self setCurrentProperty:@"title"];
    currentPostTitle = [NSString string];
    return;
}

if ( [elementName isEqualToString:@"link"] ) {
    [self setCurrentProperty:@"url"];
    currentPostUrl = [[NSURL alloc] init];
    return;
}

if ( [elementName isEqualToString:@"pubDate"] ) {
    [self setCurrentProperty:@"date"];
    currentPostDate = [[NSDate alloc] init];
    return;
}

if ( [elementName isEqualToString:@"dc:creator"] ) {
    [self setCurrentProperty:@"author"];
    currentPostAuthor = [NSString string];
    return;
}

if ( [elementName isEqualToString:@"description"] ) {
    [self setCurrentProperty:@"preview"];
    currentPostPreview = [NSString string];
    return;
}

if ( [elementName isEqualToString:@"content:encoded"] ) {
    [self setCurrentProperty:@"text"];
    currentPostText = [NSString string];
    return;
}

}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if (!currentStringValue) {
    // currentStringValue is an NSMutableString instance variable
    currentStringValue = [[NSMutableString alloc] initWithCapacity:50];
}
[currentStringValue appendString:string];
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

if ( [elementName isEqualToString:@"rss"] ) {
    return;
}
if ( [elementName isEqualToString:@"channel"]) return;

if ( [elementName isEqualToString:@"item"] ) {
    currentPost = [[DIDSEntry alloc] initWithPostTitle:currentPostTitle postAuthor:currentPostAuthor postUrl:currentPostUrl pubDate:currentPostDate postPreview:currentPostPreview postText:currentPostPreview];
    [allEntries addObject:currentPost];
    return;
}
NSString *prop = [self currentProperty];

if ( [prop isEqualToString:@"title"] ) {
    [self setCurrentPostTitle:currentStringValue];
    // return;
}

if ( [prop isEqualToString:@"url"] ) {
    [self setCurrentPostUrl:[NSURL URLWithString:currentStringValue]];
    // return;
}

if ( [prop isEqualToString:@"date"] ) {
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss ZZZ"];
    [self setCurrentPostDate:[formatter dateFromString:currentStringValue]];
    // NSLog(@"date: %@", currentStringValue);
}

if ( [prop isEqualToString:@"author"] ) {
    [self setCurrentPostAuthor:currentStringValue];
    // return;
}

if ( [prop isEqualToString:@"preview"] ) {
    [self setCurrentPostPreview:currentStringValue];
    // return;
}

if ( [prop isEqualToString:@"text"] ) {
    [self setCurrentPostText:currentStringValue];
    // return;
}
// currentStringValue is an instance variable
currentStringValue = nil;

return;
}

I’ve also kind of implemented

- (void)parser:(NSXMLParser *)parser didStartMappingPrefix:(NSString *)prefix toURI:(NSString *)namespaceURI

and

- (void)parser:(NSXMLParser *)parser didEndMappingPrefix:(NSString *)prefix

but only to log that they’re being called (they are) since I don’t know what I’m even supposed to do with them.

I’ve been all over the web trying to find an answer to why my code is behaving like this and how I might fix it but I’m completely at a loss. I tried testing for qualified names instead of element names, lopping off the prefixes, and a few other things, but no joy. (I also only superficially understand XML namespaces, though everything I’ve seen hasn’t really addressed what I’m after.)

In summation:

Trying to parse elements with namespaces and store their contents in instance variables results in the previously parsed elements being stored in those ivars. I have no idea why that’s the case and how it can be fixed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:09:27+00:00Added an answer on May 28, 2026 at 2:09 pm

    Solved. Please forgive me, but apparently this post is only tangentially related to namespaces. I did take the namespace prefixes off the element names when I checked for them, set the currentProperty string to nil after each use and noticed that I was setting the postText to currentPostPreview. Sorry. It was late.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary: How do I configure my facebook application to request additional information from the
(see here for the problem I'm trying to solve) How do you get hibernate
See here: http://code.google.com/p/ie7-js/ Does anyone have any experience or remarks about this javascript? Is
Brief summary: I need a script/plugin for Firefox that selects the load next 25
Summary: I periodically get a .NET Fatal Execution Engine Error on an application which
Summary: I want to see more detailed XML/SVG parsing error messages. I want to
I ran: git log --diff-filter=D --summary and I see the deleted file: commit abc123abc123
17:19:30,298 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS
Question Summary: how can I get the path to the currently active application under
In summary : I have an ASP.NET web page that causes an AJAX postback

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.