Recently I stumbled upon an error while trying to pass a shopping cart to the payment provider Google Checkout.
The error was:
“Error parsing XML; message from parser is: The entity “Acirc” was referenced, but not declared.”
After hunting around and a bit of searching on the net, the issued stemmed from having a `£` in a product’s option name. Removing the `£` sign seemed to fix the issue. So if you ever run into this issue it would be wise to check if there are any £ signs in your xml.
Strange error so I thought I would note it here for future ref and others to see.
4 comments
I had the same error with prestashop passing xml to GC. I need to keep that html entitity in the data being passed, though. Is there any php code that will escape the character before it hits the XML?
Hi finlander
I think:
htmlentities() http://www.php.net/manual/en/function.htmlentities.php
htmlspecialchars ( ) http://php.net/manual/en/function.htmlspecialchars.php
May help here.
follow-up:
Thank you for those links to more information. I ended up putting a DOCTYPE in my XML, specifying the specific entities to allow (in PrestaShop software).
function defined (in gc_xmlbuilder.php):
function addDOCTYPE($element) {
$this->xml .= ‘<!DOCTYPE '.$element.' [
]>’.”\n”;
}
and function called (from within the function GetXML in googlecart.php) when XML is built:
$xml_data->addDOCTYPE(‘checkout-shopping-cart’);
I don’t know of a more dynamic way of, for example, allowing all HTML entities to go through and be parsed.
Trackbacks
Our apologies, you must be logged in to post a comment.