Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP XML creator doesn't support Persian/Arabic encoding (UTF-8)
    primarykey
    data
    text
    <p>I have a problem with my php XML generator class; I used XML Creator class :</p> <pre><code>class _XmlWriter { var $xml; var $indent; var $stack = array(); function _XmlWriter($indent = ' ') { $this-&gt;indent = $indent; $this-&gt;xml = '&lt;?xml version="1.0" encoding="UTF-8"?&gt;' . "\n"; } function _indent() { for ($i = 0, $j = count($this-&gt;stack); $i &lt; $j; $i++) { $this-&gt;xml .= $this-&gt;indent; } } function push($element, $attributes = array()) { $this-&gt;_indent(); $this-&gt;xml .= '&lt;' . $element; foreach ($attributes as $key =&gt; $value) { $this-&gt;xml .= ' ' . $key . '="' . htmlentities($value) . '"'; } $this-&gt;xml .= "&gt;\n"; $this-&gt;stack[] = $element; } function element($element, $content, $attributes = array()) { $this-&gt;_indent(); $this-&gt;xml .= '&lt;' . $element; foreach ($attributes as $key =&gt; $value) { $this-&gt;xml .= ' ' . $key . '="' . htmlentities($value) . '"'; } $this-&gt;xml .= '&gt;' . htmlentities($content) . '&lt;/' . $element . '&gt;' . "\n"; } function emptyelement($element, $attributes = array()) { $this-&gt;_indent(); $this-&gt;xml .= '&lt;' . $element; foreach ($attributes as $key =&gt; $value) { $this-&gt;xml .= ' ' . $key . '="' . htmlentities($value) . '"'; } $this-&gt;xml .= " /&gt;\n"; } function pop() { $element = array_pop($this-&gt;stack); $this-&gt;_indent(); $this-&gt;xml .= "&lt;/$element&gt;\n"; } function getXml() { return $this-&gt;xml; } function create($root, $array) { $xml = new _XmlWriter(); $xml-&gt;push($root); foreach ($array as $record) { $xml-&gt;push('music', array('name' =&gt; $record[0], 'artist' =&gt; $record[1], 'album' =&gt; $record[2])); $xml-&gt;pop(); } $xml-&gt;pop(); return $xml-&gt;getXml(); } } ?&gt; </code></pre> <p>it generates XML file but doesn't support persian or arabic encoding.</p> <pre><code>XML Parsing Error: not well-formed Line Number 3, Column 98: &lt;music name="name1" artist="&amp;Ugrave;&amp;Oslash;&amp;sect;&amp;Uacute;&amp;copy;" album="album1"&gt; </code></pre> <p>when I change XML file in notepad it works in persian too, but my php class generates incorrect encoding. tnx for your help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload