알아낼 수없는 WordPress 피드의 인코딩 문제가 있습니다.PHP DomDocument, DomXPath 인코딩 문제
내 피드에 DOMDocument-> load를로드했지만 file_get_contents를 수행하고 동일한 결과로 -> XMLload를 사용하고 있습니다. 필요한 경우 피드를 조작 할 수 있도록 XMLload를 수행했습니다.
정확한 출력은 - ‘ £
입니다. Xpath 쿼리에서 echo하는 경우 - ‘ £
이 표시됩니다. utf8_decode와 함께 울리는 경우 - ? £
이 표시됩니다. 훨씬 좋지만 물음표는 아포스트로피 여야합니다.
로드 할 때 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"]);
가.
도움 주셔서 감사합니다.
아시 스 토스트가 물음표로 변하고있는 것 같습니다. 이런! 그게 유일한 문제인지 아닌지 나는 모른다.
* 귀하의 페이지 *의 인코딩은 무엇입니까? server/meta element ... –
–