I am trying to use PHP to create an XML document that will be used for an RSS feed. I've got it working for the most part, but I am getting a error on line 2 at column 29: redefinition of the xmlns prefix is forbidden
while attempting to add an attribute with a namespace to my document.
I've tried the accepted answer here:
Add rss xmlns namespace definition to a php simplexml document? but that changes the first line to <rss...
instead of <xml...
Here is the code that I am working with:
<?php
$xml = new SimpleXMLElement('<xml vesion="1.0" />');
$rss = $xml->addChild('rss');
$rss->addAttribute('version','2.0');
$rss->addAttribute("xml:base",'http://intranet/bapm/rss-avd','xml');
$rss->addAttribute('xmlns:dc',"http://purl.org/dc/elements/1.1/",'xmlns');
....
the line that adds the xml:base
attribute works fine, but when I add the line that adds the xmlns:dc
attribute I get the error. If I don't add the 'xmlns'
as the third argument, I get no errors, but the rendered attribute omits the namespace?