Jump to content

how do i add image tags to XML ?


jasonc

Recommended Posts

I wish to have all my products show in an XML for googles product search.

Also when I try to view this in internet explorer I get an error about quote marks (") being invalid.

<?
header('Content-Type: text/xml; charset=UTF-8');

include("includes/functions.php");
$connected = dbConnect();

// the DATE_FORMAT is to make the date RFCwhatsit compliant
$datetocheck = date("Y-m-d H:i:s");
$sql = "SELECT * FROM `products` ORDER BY `productTitle` ASC";
$resultset = mysql_query($sql);

//echo("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ? >\n");
echo("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<? echo('<atom:link href="http://www.site.com/rss.php" rel="self" type="application/rss+xml" />'); ?>

<channel>
<ttl>1</ttl>
<title>Welcome - RSS Feed</title>
<link>http://www.site.com?s=rssimg</link>
<description>RSS Feed</description>
<language>en-us</language>
<pubdate><?=gmdate("D, d M Y H:i:s \G\M\T");?></pubdate>
<lastbuilddate><?=date("D, d M Y H:i:s \G\M\T");?></lastbuilddate>
<generator>OnTheFly</generator>
<image>
  <title>Welcome - RSS Feed</title>
  <url>http://www.site.com/images/header.png</url>
  <link>http://www.site.com?s=rssimg</link>
  <width>88</width>
  <height>31</height>
</image>
<?php while ($result = @mysql_fetch_assoc($resultset)) {
$submitteddatetime = date("D, d M Y H:i:s \G\M\T", strtotime($datetocheck)); ?>
<item>
	<title><![CDATA[<? echo(htmlentities(stripslashes($result[productTitle]))); ?>]]></title>
	<guid>http://www.site.com<? echo("/?v=" . $result[Pid] . "&h=r"); ?></guid>
	<pubdate><? echo($submitteddatetime); ?></pubdate>
</item>
<?php
} ?>
</channel>
</rss>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.