Question

RSS feed in PHP

Asked by: cuttone

Hi,

I am trying to create a feed to submit to Google news. The code is below. What I get is an error message, where the PHP code starts to parse the data base information.

The character '>' was expected.
 Line: 13 Character: 41

Any help in getting this working is appreciated.

<? require("config.php"); ?>
 
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
 
 
<rss version="2.0">
<channel>
<title>My Site</title>
 
 
<?
 
                        $select="SELECT article_id, headline, sub_headline, created, keywords FROM $table_articles ORDER BY created DESC LIMIT 20";
 
                        $result=mysql_query($select);
 
                        while($sub_articles=mysql_fetch_array($result)) { ?>
                      echo" <item>\n"; 
                      echo" <loc><http://www.mysite.com/"article.php?article_id=<?echo $sub_articles['article_id']; ?>"></loc>\n";
                   echo"   <title> <?echo stripslashes($sub_articles['headline']);?> <?echo stripslashes($sub_articles['sub_headline']);?></title></font><br />\n";
echo" <news:news>\n";
echo" <news:publication_date><?echo stripslashes($sub_articles['created']);?></news:publication_date><br />\n";
echo" <news:keywords>Sports,  <?echo stripslashes($sub_articles['keywords']);?></news:keywords><br />\n";
                        <br /><br />  <? } ?>        </news:news>\n";
    </url>
</urlset>
 
</body>
</html>

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-12-15 at 16:20:43ID23987138
Topic

RSS

Participating Experts
2
Points
250
Comments
34

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

    Free Tech Articles

    1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
      It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
    2. SCCM OSD Basic troubleshooting
      SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
    3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
      This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
    4. Create a Win7 Gadget
      This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
    5. Outlook continually prompting for username and password
      There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
    6. Backup Exchange 2010 Information Store using Windows Backup
      There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

    Cloud Class Webinars

    1. Avoiding Bugs in Microsoft Access
      Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
    2. Top 10 Best New Features in Visio 2010
      Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
    3. IT Consultant Business Secrets Revealed
      Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
    4. Disaster Recovery and Business Continuity
      Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
    5. Organize Your Visio Diagrams with Containers and Lists
      Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
    6. How to Us Objects, Properties, Events and Methods in Microsoft Access
      Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

    Join the Community

    Give a Little. Get a Lot.

    Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

    Join the Community

    Answers

     

    by: hibridassassinPosted on 2008-12-15 at 16:38:25ID: 23179789

    I looked at the code and other than me recommending that you don't use short tags, it looks properly syntaxed.  Is the error on your config file?

     

    by: cuttonePosted on 2008-12-15 at 16:42:56ID: 23179824

    I dont think there is an error in the config file, since that is included in all the other pages on the site and they run fine

     

    by: hibridassassinPosted on 2008-12-15 at 16:44:03ID: 23179833

    I take that back, I took a closer look (before I ran it through a validator) and I see that on line 19, 20 and others, you are using echo outside of the php tags

     

    by: cuttonePosted on 2008-12-15 at 16:49:24ID: 23179893

    What is the propper code for those lines?

     

    by: hibridassassinPosted on 2008-12-15 at 16:53:37ID: 23179921

    Here give this a try and let me know if it works.

    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
     
     
    <rss version="2.0">
    <channel>
    <title>My Site</title>
     
     
    <?php
     
                            $select="SELECT article_id, headline, sub_headline, created, keywords FROM $table_articles ORDER BY created DESC LIMIT 20";
     
                            $result=mysql_query($select);
     
                            while($sub_articles=mysql_fetch_array($result)) { ?>
                            
                          <?php echo" <item>\n"; ?>
                          
                        <?php  echo" <loc><http://www.mysite.com/article.php?article_id={$sub_articles['article_id']} ></loc>\n";?>
                    <?php   echo" <title> ". stripslashes($sub_articles['headline']);?> <?php echo stripslashes($sub_articles['sub_headline']) . "</title></font><br />\n"; ?>
    <?php "<news:news>\n"; ?>
    <?php echo "<news:publication_date>" . stripslashes($sub_articles['created']) . "</news:publication_date><br />\n"; ?>
    <?php echo "<news:keywords>Sports,  " . stripslashes($sub_articles['keywords']) . "</news:keywords><br />\n"; ?>
                            <br /><br />  <?php } ?>        </news:news>\n";
        </url>
    </urlset>
     
    </body>
    </html>
    
                                                  
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    13:
    14:
    15:
    16:
    17:
    18:
    19:
    20:
    21:
    22:
    23:
    24:
    25:
    26:
    27:
    28:
    29:
    30:
    

    Select allOpen in new window

     

    by: hibridassassinPosted on 2008-12-15 at 16:56:13ID: 23179936

    don't forget to include your config file

     

    by: cuttonePosted on 2008-12-15 at 17:02:19ID: 23179963

    When the page is published as a .php file, all that shows in the browser is the line with the date and time, and the keywords.

    Looking in the source code, all the other information is there, just not visible in the browser.

    When saved as a .xml file, it returns this error:

    Whitespace is not allowed at this location.
     Line: 1 Character: 3

    <? require("config.php"); ?>

     

    by: hibridassassinPosted on 2008-12-15 at 17:06:17ID: 23179984

    You can't save it as an XML file because it has PHP code in it.  In order for the server to process that code, it has to have the extension of php...That being said, I highly recommend that you read this article that explains how to create the XML code you want with PHP:

    http://articles.techrepublic.com.com/5100-10878_11-5035149.html

     

    by: hibridassassinPosted on 2008-12-15 at 17:07:34ID: 23179993

    In other words you will use the PHP file to create a separate XML file which is what you will give to Google.  All the instructions are there.  Enjoy!

     

    by: hibridassassinPosted on 2008-12-15 at 17:10:12ID: 23180011

    One last thing, if you want to use the PHP file and give that to Google (Not sure if Google will take it) but if you do, please post the code of the source of the page you are seeing.

     

    by: cuttonePosted on 2008-12-15 at 17:36:15ID: 23180201

    Very bizarre

    I changed the site name in the file and republished the page and it gave me the same original error message.

    I copied the code exactly as a above, the only change is the url is the actual name of the web site.

     

    by: hibridassassinPosted on 2008-12-16 at 08:47:21ID: 23185306

    ummm...The other thing could be whatever data is being pulled from the database...if it has quotes or something like that, that's why I was asking to for the source of the blank page you were getting.

     

    by: Ray_PaseurPosted on 2008-12-17 at 04:36:55ID: 23192616

    Looking at this code:

    <? require("config.php"); ?>
     
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
     
    I think the effect of what you have there is to produce a line of whitespace at the top of your script.  You probably want to eliminate that.  Also, I've done a lot of RSS and I've never seen a urlset tag done that way before.  You might want to use something more like the code snippet.

    Finally, I think hibridassassin is steering you  in the right direction by suggesting that the PHP script needs to create the XML, and that the output of the script must contain only XML.  You may find it's best to let the PHP script just generate the XML and use some other mechanism to get the XML to Google.  Or you may need to have your server parse files named like .xml through the PHP processor.

    Best regards, ~Ray

    <?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
       <url>
        <loc>http://www.example.com/</loc>
       <lastmod>2008-12-17</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
       </url>  
    </urlset>
                                                  
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    

    Select allOpen in new window

     

    by: cuttonePosted on 2008-12-22 at 17:23:16ID: 23230905

    hibridassassin:

    This is what is being returned in the page as published from the baove code.

    The character '>' was expected.
     Line: 13 Character: 34

    I am not sure specifically what is in the information being pulled from the data base, but that can not be changed, since it is part of the content.

    Ray_Paseur:
    The set tags are according to Google for submitting a news feed.

    The PHP script should output the RSS feed.

     

    by: Ray_PaseurPosted on 2008-12-22 at 17:27:02ID: 23230913

    Well, if Google wants it that way, then try it that way.

    In order to get a handle on the message about The character '>' was expected.  Line: 13 Character: 34, it would be helpful if you could post the output of the script so we can see what is being generated on line 13.  You can plug that into the code snippet.

    Thanks, ~Ray

     

    by: cuttonePosted on 2008-12-22 at 17:32:07ID: 23230932

    All that shows in the web page is the error message.

    This is what is outputted in the source code:
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
     
     
    <rss version="2.0">
    <channel>
    <title>My Site</title>
     
     
                           
                           <item>
                         
                         <loc><http://www.bigapplesoccer.com/article.php?article_id=17008 ></loc>
                     <title> TAKING OVER THE CREW Warzycha gets nod in Columbus</title></font><br />
    <news:publication_date>2008-12-22 16:41:45</news:publication_date><br />
    <news:keywords>Sports,  Major League Soccer, Columbus Crew</news:keywords><br />
                            <br /><br />                          
                           <item>
                         
                         <loc><http://www.bigapplesoccer.com/article.php?article_id=17007 ></loc>
                     <title> HAPPY CHANUKAH To the Jewish soccer community</title></font><br />
    <news:publication_date>2008-12-21 21:25:35</news:publication_date><br />
    <news:keywords>Sports,  BigAppleSoccer.com</news:keywords><br />
                            <br /><br />                          
                           <item>
                         
                         <loc><http://www.bigapplesoccer.com/article.php?article_id=17005 ></loc>
                     <title> GROWTH DURING TURBULENCE RSL adds jobs during trying economic times; Dynamo and Real increase sponsors</title></font><br />
    <news:publication_date>2008-12-21 21:05:25</news:publication_date><br />
    <news:keywords>Sports,  Real Salt Lake, Houston Dynamo</news:keywords><br />
                            <br /><br />                          
                           <item>
                         
                         <loc><http://www.bigapplesoccer.com/article.php?article_id=17004 ></loc>
                     <title> SOMETIMES LESS IS MORE Unlike other sports leagues, MLS hasn't made any league office cutbacks</title></font><br />
    <news:publication_date>2008-12-21 21:01:52</news:publication_date><br />
    <news:keywords>Sports,  Major League Soccer, Don Garber</news:keywords><br />
                            <br /><br />                          
                           <item>
     

     

    by: Ray_PaseurPosted on 2008-12-22 at 17:35:55ID: 23230948

    Could you please post that using the "attach code snippet" checkbox - it will give us the line numbers.  Thanks.

     

    by: cuttonePosted on 2008-12-22 at 17:38:13ID: 23230955

    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
     
     
    <rss version="2.0">
    <channel>
    <title>My Site</title>
     
     
                            
                           <item>
                          
                         <loc><http://www.bigapplesoccer.com/article.php?article_id=17008 ></loc>
                     <title> TAKING OVER THE CREW Warzycha gets nod in Columbus</title></font><br />
    <news:publication_date>2008-12-22 16:41:45</news:publication_date><br />
    <news:keywords>Sports,  Major League Soccer, Columbus Crew</news:keywords><br />
                            <br /><br />                          
                           <item>
                          
                         <loc><http://www.bigapplesoccer.com/article.php?article_id=17007 ></loc>
                     <title> HAPPY CHANUKAH To the Jewish soccer community</title></font><br />
    <news:publication_date>2008-12-21 21:25:35</news:publication_date><br />
    <news:keywords>Sports,  BigAppleSoccer.com</news:keywords><br />
                            <br /><br />                          
                           <item>
                          
                         <loc><http://www.bigapplesoccer.com/article.php?article_id=17005 ></loc>
                     <title> GROWTH DURING TURBULENCE RSL adds jobs during trying economic times; Dynamo and Real increase sponsors</title></font><br />
    <news:publication_date>2008-12-21 21:05:25</news:publication_date><br />
    <news:keywords>Sports,  Real Salt Lake, Houston Dynamo</news:keywords><br />
                            <br /><br />                          
                           <item>
                          
                         <loc><http://www.bigapplesoccer.com/article.php?article_id=17004 ></loc>
                     <title> SOMETIMES LESS IS MORE Unlike other sports leagues, MLS hasn't made any league office cutbacks</title></font><br />
    <news:publication_date>2008-12-21 21:01:52</news:publication_date><br />
    <news:keywords>Sports,  Major League Soccer, Don Garber</news:keywords><br />
                            <br /><br />                          
                           <item>
     
    
                                                  
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    13:
    14:
    15:
    16:
    17:
    18:
    19:
    20:
    21:
    22:
    23:
    24:
    25:
    26:
    27:
    28:
    29:
    30:
    31:
    32:
    33:
    34:
    35:
    36:
    37:
    38:
    39:
    40:
    

    Select allOpen in new window

     

    by: Ray_PaseurPosted on 2008-12-22 at 17:45:49ID: 23230975

    Thanks, I think the culprit is this line:

                        <?php  echo" <loc><http://www.mysite.com/article.php?article_id={$sub_articles['article_id']} ></loc>\n";?>

    It is line 20 in hibridassassin's last post.

    Could you try changing it to something like the code snippet?  I think the extra < and > around the URL are causing the issue.

    <?php echo" <loc>http://www.mysite.com/article.php?article_id={$sub_articles['article_id']}</loc>\n";?>
    
                                                  
    1:
    

    Select allOpen in new window

     

    by: cuttonePosted on 2008-12-22 at 18:07:32ID: 23231027

    Now we get this error message:

    End tag 'news:news' does not match the start tag 'item'.
     Line: 150 Character: 36

                                     </news:news>\n";

    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
     
     
    <rss version="2.0">
    <channel>
    <title>My Site</title>
     
     
                            
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17008</loc>
                     <title> TAKING OVER THE CREW Warzycha gets nod in Columbus</title><br />
    <news:publication_date>2008-12-22 16:41:45</news:publication_date><br />
    <news:keywords>Sports,  Major League Soccer, Columbus Crew</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17007</loc>
                     <title> HAPPY CHANUKAH To the Jewish soccer community</title><br />
    <news:publication_date>2008-12-21 21:25:35</news:publication_date><br />
    <news:keywords>Sports,  BigAppleSoccer.com</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17005</loc>
                     <title> GROWTH DURING TURBULENCE RSL adds jobs during trying economic times; Dynamo and Real increase sponsors</title><br />
    <news:publication_date>2008-12-21 21:05:25</news:publication_date><br />
    <news:keywords>Sports,  Real Salt Lake, Houston Dynamo</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17004</loc>
                     <title> SOMETIMES LESS IS MORE Unlike other sports leagues, MLS hasn't made any league office cutbacks</title><br />
    <news:publication_date>2008-12-21 21:01:52</news:publication_date><br />
    <news:keywords>Sports,  Major League Soccer, Don Garber</news:keywords><br />
                   
    
                                                  
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    13:
    14:
    15:
    16:
    17:
    18:
    19:
    20:
    21:
    22:
    23:
    24:
    25:
    26:
    27:
    28:
    29:
    30:
    31:
    32:
    33:
    34:
    35:
    36:
    37:
    38:
    

    Select allOpen in new window

     

    by: Ray_PaseurPosted on 2008-12-22 at 18:17:56ID: 23231054

    Seems like it issues error messages one line at a time like the PHP parser. Grrmphff.  Any chance you could post all the way through (and past) line 150 ?  Thanks.

     

    by: cuttonePosted on 2008-12-22 at 19:48:32ID: 23231269

    Here's everything to the bottom of the page

    Thanks

    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
     
     
    <rss version="2.0">
    <channel>
    <title>My Site</title>
     
     
                            
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17009</loc>
                     <title> THE YEAR'S BEST -- NO. 9 25 years later Pancyprians rise to the top</title><br />
    <news:publication_date>2008-12-22 21:33:41</news:publication_date><br />
    <news:keywords>Sports,  N.Y. Pancyprian Freedoms, Cosmopolitan Soccer League</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17008</loc>
                     <title> TAKING OVER THE CREW Warzycha gets nod in Columbus</title><br />
    <news:publication_date>2008-12-22 16:41:45</news:publication_date><br />
    <news:keywords>Sports,  Major League Soccer, Columbus Crew</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17007</loc>
                     <title> HAPPY CHANUKAH To the Jewish soccer community</title><br />
    <news:publication_date>2008-12-21 21:25:35</news:publication_date><br />
    <news:keywords>Sports,  BigAppleSoccer.com</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17005</loc>
                     <title> GROWTH DURING TURBULENCE RSL adds jobs during trying economic times; Dynamo and Real increase sponsors</title><br />
    <news:publication_date>2008-12-21 21:05:25</news:publication_date><br />
    <news:keywords>Sports,  Real Salt Lake, Houston Dynamo</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17004</loc>
                     <title> SOMETIMES LESS IS MORE Unlike other sports leagues, MLS hasn't made any league office cutbacks</title><br />
    <news:publication_date>2008-12-21 21:01:52</news:publication_date><br />
    <news:keywords>Sports,  Major League Soccer, Don Garber</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17003</loc>
                     <title> THE YEAR'S BEST -- NO. 10 Vicki DiMartino finds a silver lining</title><br />
    <news:publication_date>2008-12-21 20:56:36</news:publication_date><br />
    <news:keywords>Sports,  </news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17002</loc>
                     <title> REMEMBERING MOOCH U.S. Soccer Foundation has Myernick fund</title><br />
    <news:publication_date>2008-12-21 09:34:20</news:publication_date><br />
    <news:keywords>Sports,  Glenn "Mooch" Myernick</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17001</loc>
                     <title>  </title><br />
    <news:publication_date>2008-12-21 08:34:34</news:publication_date><br />
    <news:keywords>Sports,  </news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=17000</loc>
                     <title> SCHOLARSHIPS AVAILABLE ENYYSA: For H.S. seniors in 2009</title><br />
    <news:publication_date>2008-12-21 00:03:48</news:publication_date><br />
    <news:keywords>Sports,  Eastern New York Youth Soccer Association</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16999</loc>
                     <title> FANTASTIC FOUR Grecco, Rodriguez, Friedman, Turchi are inducted into ENY Soccer Hall of Fame</title><br />
    <news:publication_date>2008-12-21 00:01:56</news:publication_date><br />
    <news:keywords>Sports,  Eastern New York Soccer Hall of Fame, Eastern New York Youth Soccer Association, Eastern New York State Amateur Soccer Association</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16997</loc>
                     <title> ROAD KILL Ironmen lose at Ignition in OT, 16-14</title><br />
    <news:publication_date>2008-12-20 23:56:09</news:publication_date><br />
    <news:keywords>Sports,  New Jersey Ironmen</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16996</loc>
                     <title>  </title><br />
    <news:publication_date>2008-12-20 18:22:46</news:publication_date><br />
    <news:keywords>Sports,  </news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16995</loc>
                     <title> THE RANDY VOGT FILE Facts about his officiating career</title><br />
    <news:publication_date>2008-12-20 12:15:12</news:publication_date><br />
    <news:keywords>Sports,  Long Island Junior Soccer League</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16993</loc>
                     <title> THE AMAZING RANDY Some 7,000 games and 30 years as a referee, Vogt is still alive and whistling</title><br />
    <news:publication_date>2008-12-20 11:49:09</news:publication_date><br />
    <news:keywords>Sports,  Long Island Junior Soccer League</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16992</loc>
                     <title> SECOND TEAM NCC's Alaja junior college All-America</title><br />
    <news:publication_date>2008-12-19 14:08:23</news:publication_date><br />
    <news:keywords>Sports,  Nassau Community College, National Soccer Coaches Association of American</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16991</loc>
                     <title> ON SALE SOON Tickets for Sky Blue opener -- on Dec. 29</title><br />
    <news:publication_date>2008-12-19 13:58:04</news:publication_date><br />
    <news:keywords>Sports,  Sky Blue FC, Women's Professional Soccer</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16990</loc>
                     <title> ABOUT THIS WEBSITE The ins and outs of BigAppleSoccer.com</title><br />
    <news:publication_date>2008-12-19 13:20:58</news:publication_date><br />
    <news:keywords>Sports,  BigAppleSoccer.com</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16989</loc>
                     <title> LIJSL SPORTSMANSHIP Plaques can be picked up through Dec. 23</title><br />
    <news:publication_date>2008-12-19 08:51:21</news:publication_date><br />
    <news:keywords>Sports,  Long Island Junior Soccer League</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16988</loc>
                     <title> OFFSIDE REMARKS Some soccer games for holiday gifts</title><br />
    <news:publication_date>2008-12-19 08:28:51</news:publication_date><br />
    <news:keywords>Sports,  Michael Lewis</news:keywords><br />
                                                     
                           <item>
                          
                         <loc>http://www.bigapplesoccer.com/article.php?article_id=16987</loc>
                     <title> TOP HONORS Howard, Sacha U.S. Soccer players of year</title><br />
    <news:publication_date>2008-12-18 19:00:45</news:publication_date><br />
    <news:keywords>Sports,  Tim Howard, U.S. Soccer, Sacha Kljestan</news:keywords><br />
                                     </news:news>\n";
        </url>
    </urlset>
     
     
    </body>
    </html>
                                                  
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    13:
    14:
    15:
    16:
    17:
    18:
    19:
    20:
    21:
    22:
    23:
    24:
    25:
    26:
    27:
    28:
    29:
    30:
    31:
    32:
    33:
    34:
    35:
    36:
    37:
    38:
    39:
    40:
    41:
    42:
    43:
    44:
    45:
    46:
    47:
    48:
    49:
    50:
    51:
    52:
    53:
    54:
    55:
    56:
    57:
    58:
    59:
    60:
    61:
    62:
    63:
    64:
    65:
    66:
    67:
    68:
    69:
    70:
    71:
    72:
    73:
    74:
    75:
    76:
    77:
    78:
    79:
    80:
    81:
    82:
    83:
    84:
    85:
    86:
    87:
    88:
    89:
    90:
    91:
    92:
    93:
    94:
    95:
    96:
    97:
    98:
    99:
    100:
    101:
    102:
    103:
    104:
    105:
    106:
    107:
    108:
    109:
    110:
    111:
    112:
    113:
    114:
    115:
    116:
    117:
    118:
    119:
    120:
    121:
    122:
    123:
    124:
    125:
    126:
    127:
    128:
    129:
    130:
    131:
    132:
    133:
    134:
    135:
    136:
    137:
    138:
    139:
    140:
    141:
    142:
    143:
    144:
    145:
    146:
    147:
    148:
    149:
    150:
    151:
    152:
    153:
    154:
    155:
    156:
    

    Select allOpen in new window

     

    by: Ray_PaseurPosted on 2008-12-23 at 14:14:02ID: 23237238

    Regarding this thing on line 150:

                        </news:news>\n";

    That looks like spurious junk.  I would suggest you just cut it out of the script - it's an ending tag with no opening tag.

    But that raises an important question, namely, where are the </item> tags that are required to close each <item> declaration?

    If you would, please post the PHP script that you are using to generate the XML file, and I'll see if there is a quick fix.

    Best regards, ~Ray

     

    by: cuttonePosted on 2008-12-23 at 19:11:03ID: 23238333

    Below is the entire code as it is now.

    Also, here is the information from Google in what they require in a news feed.

    <?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
       <url>
          <loc>http://example.com/article123.html</loc>
       
      <news:news>
             <news:publication_date> 2006-08-14T03:30:00Z </news:publication_date>
             <news:keywords>Business, Mergers, Acquisitions</news:keywords>        
          </news:news>
       </url>
    </urlset>

    <? require("config.php"); ?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
     
     
    <rss version="2.0">
    <channel>
    <title>My Site</title>
     
     
    <?php $select="SELECT article_id, headline, sub_headline, created, keywords FROM $table_articles ORDER BY created DESC LIMIT 20";
     
                            $result=mysql_query($select);
     
                            while($sub_articles=mysql_fetch_array($result)) { ?>
                            
                          <?php echo" <item>\n"; ?>
                          
                        <?php  echo" <loc>http://www.bigapplesoccer.com/article.php?article_id={$sub_articles['article_id']}</loc>\n";?>
                    <?php   echo" <title> ". stripslashes($sub_articles['headline']);?> <?php echo stripslashes($sub_articles['sub_headline']) . "</title><br />\n"; ?>
    <?php "<news:news>\n"; ?>
    <?php echo "<news:publication_date>" . stripslashes($sub_articles['created']) . "</news:publication_date><br />\n"; ?>
    <?php echo "<news:keywords>Sports,  " . stripslashes($sub_articles['keywords']) . "</news:keywords><br />\n"; ?>
                             <?php } ?>        </news:news>\n";
        </url>
    </urlset>
     
     
    </body>
    </html>
                                                  
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    13:
    14:
    15:
    16:
    17:
    18:
    19:
    20:
    21:
    22:
    23:
    24:
    25:
    26:
    27:
    28:
    29:
    30:
    

    Select allOpen in new window

     

    by: Ray_PaseurPosted on 2008-12-24 at 07:29:11ID: 23240409

    From the look of that Google code, their news feed is not "strictly speaking" RSS, so we'll try to give them what they want, following the template above.

     

    by: Ray_PaseurPosted on 2008-12-24 at 07:43:24ID: 23240487

    This may work a little better.  I cannot test it, so feel free to correct any typos or parse errors.

    Best of luck, ~Ray

    <? require("config.php"); ?>
    <?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
    <?php 
    // SELECT THE INFORMATION
    $select="SELECT article_id, headline, sub_headline, created, keywords FROM $table_articles ORDER BY created DESC LIMIT 20";
    if (!$result=mysql_query($select)) die( mysql_error() );
     
    // ITERATE OVER THE RESULT SET, GENERATING THE GOOGLE STUFF
    while($s=mysql_fetch_assoc($result)) 
    { 
     
    // REFORMAT DATE AS SHOWN IN GOOGLE EXAMPLE
    	$sdate	= date('Y-m-d\TH:i:s', strtotime($s['created'])) . 'Z';
    	
    // SPEW THE INFORMATION GOOGLE WANTS FOR EACH NEWS ITEM	
    	echo "<url>\n";
    	echo "<loc>http://www.bigapplesoccer.com/article.php?article_id={$s['article_id']}</loc>\n";
    // THIS <title> LINE IS NOT SHOWN IN GOOGLE EXAMPLE - ??
    	echo "<title>{$s['headline']} {$s['sub_headline']}</title>\n";
    	echo "<news:news>\n"; 
    	echo "<news:publication_date>$sdate</news:publication_date>\n";
    	echo "<news:keywords>Sports, " . $s['keywords'] . "</news:keywords>\n";
            echo "</news:news>\n";
        	echo "</url>\n";
    } // END ITERATOR
    ?>
    </urlset>
    
                                                  
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    13:
    14:
    15:
    16:
    17:
    18:
    19:
    20:
    21:
    22:
    23:
    24:
    25:
    26:
    27:
    28:
    

    Select allOpen in new window

     

    by: Ray_PaseurPosted on 2008-12-24 at 07:44:19ID: 23240499

    Oops, correct that first line as shown below.  And never plan to use short tags if you are also using XML!

    <?php require("config.php"); ?>
                                                  
    1:
    

    Select allOpen in new window

     

    by: cuttonePosted on 2008-12-24 at 11:15:05ID: 23241556

    I ran it as above, and now i am geting this:

    Parse error: parse error, unexpected T_STRING in /usr/home/sites/www.bigapplesoccer.com/web/sitemap-news.php on line 2

    The error seems to be in parsing the XML in line 2.

     

    by: Ray_PaseurPosted on 2008-12-24 at 13:29:44ID: 23242003

    I'll give you a slightly different version.  PHP and XML are having a syntax collision!

     

    by: Ray_PaseurPosted on 2008-12-24 at 13:31:54ID: 23242012

    Try this and see if it helps...

    <?php
    // BRING IN THE COMMON DATA ELEMENTS
    require_once("config.php");
     
    // WRITE THE XML HEADERS
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    echo "<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\" xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\">\n";
     
    // SELECT THE INFORMATION
    $select="SELECT article_id, headline, sub_headline, created, keywords FROM $table_articles ORDER BY created DESC LIMIT 20";
    if (!$result=mysql_query($select)) die( mysql_error() );
     
    // ITERATE OVER THE RESULT SET, GENERATING THE GOOGLE STUFF
    while($s=mysql_fetch_assoc($result)) 
    { 
     
    // REFORMAT DATE AS SHOWN IN GOOGLE EXAMPLE
    	$sdate	= date('Y-m-d\TH:i:s', strtotime($s['created'])) . 'Z';
    	
    // SPEW THE INFORMATION GOOGLE WANTS FOR EACH NEWS ITEM	
    	echo "<url>\n";
    	echo "<loc>http://www.bigapplesoccer.com/article.php?article_id={$s['article_id']}</loc>\n";
    // THIS <title> LINE IS NOT SHOWN IN GOOGLE EXAMPLE - ??
    	echo "<title>{$s['headline']} {$s['sub_headline']}</title>\n";
    	echo "<news:news>\n"; 
    	echo "<news:publication_date>$sdate</news:publication_date>\n";
    	echo "<news:keywords>Sports, " . $s['keywords'] . "</news:keywords>\n";
            echo "</news:news>\n";
        	echo "</url>\n";
    } // END ITERATOR
     
    echo "</urlset>\n";
    ?>
                                                  
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    13:
    14:
    15:
    16:
    17:
    18:
    19:
    20:
    21:
    22:
    23:
    24:
    25:
    26:
    27:
    28:
    29:
    30:
    31:
    32:
    33:
    

    Select allOpen in new window

     

    by: cuttonePosted on 2008-12-24 at 14:06:41ID: 23242110

    It's not putting out the XML.

    Here's a link to the page, so you can see what is happening

    http://www.bigapplesoccer.com/sitemap-news.php

    I really appreciate the help with this.

     

    by: Ray_PaseurPosted on 2008-12-24 at 15:05:04ID: 23242223

    Earlier, you posted this:

    Also, here is the information from Google in what they require in a news feed.

    <?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
       <url>
          <loc>http://example.com/article123.html</loc>
       
      <news:news>
             <news:publication_date> 2006-08-14T03:30:00Z </news:publication_date>
             <news:keywords>Business, Mergers, Acquisitions</news:keywords>        
          </news:news>
       </url>
    </urlset>

    And that appears to be what the script is producing.  Can you give me the link to the Google page that describes the format?  Maybe I can find something if I read Google's instructions.

     

    by: cuttonePosted on 2008-12-24 at 15:11:03ID: 23242229

    Maybe I am missing something. When I look at the page, it is not showing the formating, however it does in the source code.

    Here is the Google help page

    http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=74288

     

    by: Ray_PaseurPosted on 2008-12-24 at 15:23:48ID: 23242257

    The Google help page describes the Google News sitemap, a a file that allows you to have more control over the content you submit to Google News. It also helps speed up the discovery of your pages, an important first step in the article crawling and indexing processes.  

    This is not an RSS file, and the format of the information we are producing appears to be correct and in consonance with the instructions.

    Have you tried submitting this to Google?

    I am posting a new script here - it looks like you have somehow gotten slashes into your data base, possibly through the collision between magic_quotes and addslashes.  This change will take them out of the title tags.   However you will need to read the Google man pages carefully and determine whether the title tags are appropriate in the Google News sitemap.  I can't make that decision for you.

    Best of luck, ~Ray

    <?php
    // BRING IN THE COMMON DATA ELEMENTS
    require_once("config.php");
     
    // WRITE THE XML HEADERS
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    echo "<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\" xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\">\n";
     
    // SELECT THE INFORMATION
    $select="SELECT article_id, headline, sub_headline, created, keywords FROM $table_articles ORDER BY created DESC LIMIT 20";
    if (!$result=mysql_query($select)) die( mysql_error() );
     
    // ITERATE OVER THE RESULT SET, GENERATING THE GOOGLE STUFF
    while($s=mysql_fetch_assoc($result)) 
    { 
     
    // REFORMAT DATE AS SHOWN IN GOOGLE EXAMPLE
    	$sdate	= date('Y-m-d\TH:i:s', strtotime($s['created'])) . 'Z';
    	
    // SPEW THE INFORMATION GOOGLE WANTS FOR EACH NEWS ITEM	
    	echo "<url>\n";
    	echo "<loc>http://www.bigapplesoccer.com/article.php?article_id={$s['article_id']}</loc>\n";
     
     
     
     
    // NOTE THIS ISOLATED SEGMENT OF CODE
    // THIS <title> LINE IS NOT SHOWN IN GOOGLE EXAMPLE - ??
    	$headline	= stripslashes($s['headline']);
    	$sub_headline	= stripslashes($s['sub_headline']);
    	echo "<title>$headline $sub_headline</title>\n";
    	
    	
     
     
    	
    	echo "<news:news>\n"; 
    	echo "<news:publication_date>$sdate</news:publication_date>\n";
    	echo "<news:keywords>Sports, " . $s['keywords'] . "</news:keywords>\n";
            echo "</news:news>\n";
        	echo "</url>\n";
    } // END ITERATOR
     
    echo "</urlset>\n";
    ?>
    
                                                  
    1:
    2:
    3:
    4:
    5:
    6:
    7:
    8:
    9:
    10:
    11:
    12:
    13:
    14:
    15:
    16:
    17:
    18:
    19:
    20:
    21:
    22:
    23:
    24:
    25:
    26:
    27:
    28:
    29:
    30:
    31:
    32:
    33:
    34:
    35:
    36:
    37:
    38:
    39:
    40:
    41:
    42:
    43:
    44:
    45:
    

    Select allOpen in new window

    20120131-EE-VQP-002

    3 Ways to Join

    30-Day Free Trial

    The Experts

    98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

    He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

    The Experts

    97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

    The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

    Testimonials

    "...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

    Testimonials

    "I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

    Testimonials

    "WOW! You guys have great, active, and knowledgeable people on here." moore50

    Business Clients

    Business Clients

    In the Press

    "If you’ve got a question... Experts Exchange can supply an answer.”

    In the Press

    "...an invaluable aid for both IT professionals and those who require tech support."

    In the Press

    "where IT professionals provide quick answers on just about any topic"

    Business Account Plans

    Loading Advertisement...