PHP's SimpleXML not handling ’ ; properly
Posted
by
Matty
on Stack Overflow
See other posts from Stack Overflow
or by Matty
Published on 2011-01-12T08:09:31Z
Indexed on
2011/01/12
8:53 UTC
Read the original article
Hit count: 550
I'm parsing an RSS feed that has an ’
in it. SimpleXML turns this into a ’. What can I do to stop this?
Just to answer some of the questions that have come up - I'm pulling an RSS feed using CURL. If I output this directly to the browser, the ’
displays as ’ which is what's expected. When I create a new SimpleXMLElement using this, (e.g. $xml = new SimpleXmlElement($raw_feed);
and dump the $xml
variable, every instance of ’
is replaced with ’.
It appears that SimpleXML is having trouble with UTF-8 ampersand encoded characters. (The XML declaration specifies UTF-8.)
I do have control over the feed after CURL has retrieved the feed before it's used to construct a SimpleXML element.
© Stack Overflow or respective owner