我在wordpress提要的编码上遇到了一个问题,我似乎无法理解。
我正在用DOMDocument加载feed->加载但之后文件\u获取了\u内容,我现在使用->XMLload具有相同的结果。我做了XMLload以便在需要时可以操纵提要。
我要找的正确输出是
- ‘ £
.
- ‘ £
如果我用utf8\u解码回显
- ? £
好多了,但问号应该是撇号。
如果在加载DomDocument时循环遍历它的每个节点,则会得到正确的输出。所以在XPath中似乎处理不正确。
有什么想法吗?
饲料是
http://shredeasy.com/blog/category/news/feed
function getPostsInCategory($feed=NULL){
if(is_null($feed)){ echo "Wrong Usage. Need a valid Category Feed. Most likely from getCategories()."; return false; }
$feedx = file_get_contents($feed);
$xml = new DOMDocument();
$xml->loadXML($feedx);
//$this->showDOMNode($xml);
//$xml->load($feed);
$xpath = new DomXPath($xml);
$xpath->registerNamespace("content", "http://web.resource.org/rss/1.0/modules/content/");
$cat = array();
foreach($xml->getElementsByTagName('item') as $c){
$elements = array();
$elements["title"] = $xpath->query("title", $c)->item(0)->nodeValue;
echo utf8_decode($elements["title"]);
几个小时来我一直在想这个问题,但我总是绕着错误的方向转。
你知道的,似乎撇号正在变成问号……天哪!我不知道这是不是唯一的问题。