Question

I have been testing my PHP app to list items on eBay using their Trading API. I have been having success in my testing but I just came accross some items with ampersand in the title.

This error keeps getting returned.

XML Error Text: "; nested exception is: 
    org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference

What its telling me is that I cant simply pass the ampersand symbol.

To remedy the problem I have tried several things:

$string = 'LEUPOLD 66325 4.5-14x50 VX-3 RIFLE SCOPE - SILVER, B&C BOONE & CROCKETT RETICLE';
echo str_replace("&","&",$string);
echo str_replace("&","&",$string);
echo htmlspecialchars($string,ENT_NOQUOTES);
echo htmlspecialchars($string);
echo htmlspecialchars_decode($string);

also tried it like this

<![CDATA['.$string.']]>

No matter what I do, it does not succeed when I pass it through.

Thanks all for your help.

Was it helpful?

Solution

Is the data you're submitting in UTF8? That could be your problem if it's not.

http://developer.ebay.com/Devzone/return-management/Concepts/MakingACall.html#utf8encoding

All parameter values should be encoded in UTF-8 format. UTF-8 is the default encoding for API requests.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top