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

  • Home
  • SEARCH
  • 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 7196147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:43:22+00:00 2026-05-28T20:43:22+00:00

I have a php as follows: <?php header(Content-Type: application/rss+xml; charset=ISO-8859-1); $ip=$_GET[‘ip’]; $type=$_GET[‘type’]; $rssfeed =

  • 0

I have a php as follows:

<?php
    header("Content-Type: application/rss+xml; charset=ISO-8859-1");
    $ip=$_GET['ip'];
    $type=$_GET['type'];
    $rssfeed = '<?xml version="1.0" encoding="ISO-8859-1"?>';
    $rssfeed .= '<rss version="2.0">';
    $connection = mysql_connect('localhost','root')
    or die('Could not connect to database');
    mysql_select_db('Android')
    or die ('Could not select database');
    $query = "SELECT * FROM User_Upload_Table WHERE Status='Approved' and Content_Type='$type' ORDER BY Approved_Time desc";
    $result = mysql_query($query) or die ("Could not execute query");
    while($row = mysql_fetch_array($result)) {
            extract($row);
            $rssfeed .= "<channel>";
            $rssfeed .= "<title>" .$row[Content_Name] ."</title>";
            $rssfeed .= '<link>http://'.$ip .$row[Content_Path] .$row[Status] . '/' .$row[Content_Name] . '</link>';
            if($type == "Video"){
          $rssfeed .= '<description>' .$row[Duration]. '</description>';
            }
            $rssfeed .= '<category>' .$row[Description]. '</category>';
            $rssfeed .= '<rating>' .$row[Rating]. '</rating>';
            $rssfeed .= '<generator>' .$row[Vote_Count]. '</generator>';
            $rssfeed .= '<language></language>';
            if($type == "Video"){
              $name = $row[Content_Name];
              $subName = substr($name, 0, strpos($name, '.'));
              $rssfeed .= '<image>http://'.$ip.'/Android/'.$type.'/'.$subName.'.jpg</image>';
            } else {
              $rssfeed .= '<image>http://'.$ip.'/Android/'.$type.'/Approved.jpg</image>';
            }
            $rssfeed .= '<copyright>Copyright 2011</copyright>';
            $rssfeed .= '<item>';
            $rssfeed .= '<title>Pre-Roll</title>';
            $rssfeed .= '<link>http://'.$ip.'/Android/Video/Approved/MERCEDES_BENZ.3gp</link>';
            $rssfeed .= '<description>Post-Roll</description>';
            $rssfeed .= '<source>http://'.$ip.'/Android/Video/Approved/PG_Dawn_PGDN4582000_30.mp4</source>';
            $rssfeed .= '</item>';
            $rssfeed .= '</channel>';
    }
    $rssfeed .= '</rss>';
    echo $rssfeed;
?>

Here i have two fields with the name title, one in channel and the other in item attribute. How can I parse it separately. My parsing code is as follows:

  -(void)parseXMLFileAtURL:(NSString *)URL{

  NSURL *xmlURL = [NSURL URLWithString:URL];
  rssParser = [[NSXMLParser alloc]initWithContentsOfURL:xmlURL];
  [rssParser setDelegate:self];
  [rssParser setShouldProcessNamespaces:NO];
  [rssParser setShouldReportNamespacePrefixes:NO];
  [rssParser setShouldResolveExternalEntities:NO];
  [rssParser parse];
  NSLog(@"Parsed");
}

-(void)parserDidStartDocument:(NSXMLParser *)parser{

    NSLog(@"Found file and started parsing");
}


-(void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError{

NSString *errorString = [NSString stringWithFormat:@"Unable to download feed from website (Error Code %i)", [parseError code]];
NSLog(@"Error parsing xml: %@", errorString);
UIAlertView *errorAlert = [[UIAlertView alloc]initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}


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

  insideItem = FALSE;
  insideChannel = FALSE;

  rssElement      = [[NSMutableDictionary alloc]init];

  currentElement = [elementName copy];
  if ([elementName isEqualToString:@"channel"]) {

    title           = [[NSMutableString alloc]init];
    link            = [[NSMutableString alloc]init];
    description     = [[NSMutableString alloc]init];
    copyright       = [[NSMutableString alloc]init];
    image           = [[NSMutableString alloc]init];
  }
}


-(void)parser: (NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{

  if ([elementName isEqualToString:@"channel"]) {

    [rssElement setObject:title                 forKey:@"title"];
    [rssElement setObject:link                  forKey:@"link"];
    [rssElement setObject:description           forKey:@"description"];
    [rssElement setObject:copyright             forKey:@"copyright"];
    [rssElement setObject:image                 forKey:@"image"];

    [item addObject:[rssElement copy]];
    NSLog(@"adding stories %@", title);

  }
}


-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{

  if ([currentElement isEqualToString:@"title"]) {
    [title appendString:string];
  }else if ([currentElement isEqualToString:@"link"]) {
    [link appendString:string];
  }else if ([currentElement isEqualToString:@"description"]) {
    [description appendString:string];
  }else if ([currentElement isEqualToString:@"copyright"]) {
    [copyright appendString:string];
  }else if ([currentElement isEqualToString:@"image"]) {
     [image appendString:string];
  }
}

-(void)parserDidEndDocument:(NSXMLParser *)parser{

    NSLog(@"all done");
    NSLog(@"item array has %d items", [item count]);
    [tableView reloadData];
    NSLog(@"Finished Parsing");
}

Now, the problem is when I am displaying the feed in a table view, the two title fields are getting appended but I need to display only the title field of channel attribute.

Please help me and let me know what is that I am doing wrong.

The proper code will be of immense help in this regard.

  • 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-28T20:43:22+00:00Added an answer on May 28, 2026 at 8:43 pm

    In didStartElement, push the current tag to a stack. In didEndElement, pop it from the stack. Then you can always check the stack for the parent element and distinguish between the channel’s title element and the item’s title element.

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

Sidebar

Related Questions

I have this problem where all URLs like context/path/file/anything/that/follows becomes context/path/file.php/anything/that/follows or context/path/file.xml/anything/that/follows .
I have a string which follows literally : lt;img src=quot;http://www.news.gov.tt/thumbnail.php?file=Hon__Jerry_Narace_Minister__Of_Health_599152837.jpgamp;size=summary_mediumquot;gt;lt;pgt;Fifty-eight people have been tested
I have code as follows: $(#item_select).change(function() { var params = $(#item_select option:selected).val(); $.post('/account/ar_form.php', {idata:
I have a Java application that I need to integrate our existing PHP website
I have the following php code (getRout.php).. which response results in xml formats ...
I have PHP configured so that magic quotes are on and register globals are
We have PHP 5.2.6 deployed to c:\php and in that folder there is the
I have PHP 5.1.6 running with a ton of mods and extensions enabled, is
I have php script that creates a temporary watermark image for users that are
I have PHP scrip that goes like this: if ($cost_frm < $cost){ echo <script

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.