I'm attempting to create a valid product feed for google shopping. All is well except this issue here.
DOMDocument() is creating this:
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0"/>
Whereas the objective is this:
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">
Note the missing "/"
I thought < /> was perfectly valid code, but google is rejecting it with this error:
XML formatting error - Error
Our system encountered an error when processing your data feed. Learn more. Examples: Line Nr. 3 Column Nr. 1
That of course relates to the above tag I mentioned.
The doc starts off this way...
<?xml version="1.0"?>
<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0"/>
<channel>
...
I'm not aware there are any issues, yet google says its in error.
<?php
$xml = new DOMDocument();
$rss = $xml->createElement('rss');
$version = $xml->createAttribute('version');
$rss->appendChild($version);
$value = $xml->createTextNode('2.0');
$version->appendChild($value);
$xmlns_g = $xml->createAttribute('xmlns:g');
$rss->appendChild($xmlns_g);
$value = $xml->createTextNode('http://base.google.com/ns/1.0');
$xmlns_g->appendChild($value);
$xmlns_c = $xml->createAttribute('xmlns:c');
$rss->appendChild($xmlns_c);
$value = $xml->createTextNode('http://base.google.com/cns/1.0');
$xmlns_c->appendChild($value);
$xml->appendChild($rss);
?>