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 7195447
In Process

The Archive Base Latest Questions

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

I have code which is creating a XML document for Google Shopping. Google is

  • 0

I have code which is creating a XML document for Google Shopping. Google is getting hung up on a blank line. I do not know how to strip the lines out. The code is pulling from a Magento Commerce database.

<?php echo '<?xml version="1.0" ?>'; ?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://www.base.google.com/cns/1.0">
<channel>
<title>Spray Foam Systems</title>
<link>http://www.sprayfoamsys.com/store/</link>
<description>Spray Foam Rigs, Spray Foam Equipment, Sprayfoam Parts and Supplies.</description>

<?php
$con = mysql_connect(REMOVED) or die(mysql_error());
    if (!$con)
        {
            die('Could not connect: ' . mysql_error());
        }
    mysql_select_db("sprayfoa_store", $con);

    $query = mysql_query("SELECT * FROM `catalog_product_flat_1` WHERE `visibility` = 4 ORDER BY entity_id ASC")
    or die(mysql_error());
?>

<?php
    while($row = mysql_fetch_array($query))
        {
?>
<item>
<g:id><?php echo $row['entity_id']; ?></g:id>
<title><?php echo $row['name']; ?></title>
<description><?php echo $row['short_description']; ?></description>
<g:google_product_category>Business &amp; Industrial &gt; Construction</g:google_product_category>
<g:product_type>Spray Foam Parts &amp; Supplies &gt; Fusion AP Parts</g:product_type>
<link>http://sprayfoamsys.com/store/<?php echo $row['url_path']; ?></link>
<g:image_link>http://sprayfoamsys.com/store/media/catalog/product<?php echo $row['small_image']; ?></g:image_link>
<g:condition>new</g:condition>
<g:availability>in stock</g:availability>
<g:price><?php echo $row['price']; ?></g:price>
<g:brand>
<?php
$entity_id = $row['entity_id'];
$query2 = mysql_query("SELECT * FROM `catalog_product_entity_varchar` WHERE entity_id = '$entity_id' AND attribute_id = '127'")
or die(mysql_error());  
    while($row2 = mysql_fetch_array($query2))
        {
            echo $row2['value'];
} ?>
</g:brand>
<g:mpn><?php echo $row['sku']; ?></g:mpn>
</item>


<?php
}
mysql_close($con);
?>

</channel>
</rss>

The output looks like:

<item>
<g:id>15</g:id>
<title>DK 817 - Gun Cleaning Solvent and Lubricator - Aerosol Can 16 oz. </title>
<description>DK 817 is a cleaner-lubricant used on for cleaning polyurethane dispensing equipment and guns.  DK817 comes in a 16 oz. aerosol can.  Contractors praise it's ability to quickly clean components with uncured polyurethane materials.  </description>
<g:google_product_category>Business &amp; Industrial &gt; Construction</g:google_product_category>
<g:product_type>Spray Foam Parts &amp; Supplies &gt; Fusion AP Parts</g:product_type>
<link>http://sprayfoamsys.com/store/dk-817-gun-cleaning-solvent-and-lubricator-aerosol-can.html</link>
<g:image_link>http://sprayfoamsys.com/store/media/catalog/product/d/k/dk817.jpg</g:image_link>
<g:condition>new</g:condition>
<g:availability>in stock</g:availability>
<g:price>24.9900</g:price>
<g:brand>brand
</g:brand>
<g:mpn>partnumber</g:mpn>
</item>


<item>
<g:id>16</g:id>
<title>Allegro Full Mask SAR Replacement Lens 9901-09L</title>
<description>Replacement lens for the 9901 Series Allegro Full Face Mask.  Clear, scratch resistant lens.  Easy to replace.  Lens only.

Allegro 9901-09L</description>
<g:google_product_category>Business &amp; Industrial &gt; Construction</g:google_product_category>
<g:product_type>Spray Foam Parts &amp; Supplies &gt; Fusion AP Parts</g:product_type>
<link>http://sprayfoamsys.com/store/allegro-full-mask-sar-replacement-lens-9901-09r.html</link>
<g:image_link>http://sprayfoamsys.com/store/media/catalog/product/a/l/al-9901-09l-1.jpg</g:image_link>
<g:condition>new</g:condition>
<g:availability>in stock</g:availability>
<g:price>75.0000</g:price>
<g:brand>
Allegro</g:brand>
<g:mpn>9901-09L</g:mpn>
</item>

The first item passes through no problem as the description tag has no blank lines, however the second item, give me a XML formatting error, the only thing I can think of is the blank line in the description tag

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

    You could try stripping out the newlines like this

    <description><?php echo str_replace(array("\r\n", "\n"), ' ', $row['short_description']); ?></description>
    

    See the str_replace() function in the PHP manual.

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

Sidebar

Related Questions

I have code that creates an XML document that is difficult to read in
I have code which needs to do something like this There is a list
I have code which looks like: private static DirectiveNode CreateInstance(Type nodeType, DirectiveInfo info) {
I have code which as been working against an older Active Directory server and
I already have code which lazy loads scripts on request. My issue now is
I have some code which collects points (consed integers) from a loop which looks
I have have some code which adds new cells to a table and fills
I have some code which utilizes parameterized queries to prevent against injection, but I
I have some code which I am making available via RMI. If my program
I have some code which needs to ensure some data is in a mysql

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.