0
私はPHPでのXMLファイルを作成しています、これは私がこれだけエンコーディング・エラー(HTMLエンティティ)
<?xml version="1.0" encoding="UTF-8"?>
<ad_list><ad_item class="class"><description_raw>Lorem ipsum dolor sit amet
を参照してくださいソースで
error on line 2 at column 165: Encoding error
Below is a rendering of the page up to the first error.
を取得し、出力されますこれは私が使用しているコードです(strip_shortcodes
はWordpressが使用するタグを削除するためのWordpress関数です)。
$xml = new DOMDocument('1.0', 'UTF-8');
$xml__item = $xml->createElement("ad_list");
$ad_item = $xml->createElement("ad_item");
$xml__item->appendChild($ad_item);
$description_raw = $xml->createElement("description_raw", strip_shortcodes(html_entity_decode(get_the_content())));
$ad_item->appendChild($description_raw);
$xml->appendChild($xml__item);
$xml->save($filename);
私は完全なXMLが生成されているよりもdescription_raw
からhtml_entity_decode
機能を削除したが、その後、私はこのエラーを持っている
error on line 6 at column 7: Entity 'nbsp' not defined
Below is a rendering of the page up to the first error.
'' それは正しい方法で復号し、XMLで有効なエンティティではありません。しかし、あなたは 'DOMDocument :: createElement()'の2番目の引数を使っています。これは壊れています:http://stackoverflow.com/questions/22956330/cakephp-xml-utility-library-triggers-domdocument-warning/22957785#22957785 – ThW