Page 1 of 1
How do I add encoding to DOM XML in PHP4?
Posted: Sat Jan 20, 2007 6:04 am
by nadavvin
The method "domxml_new_doc" get only one parameter of the xml version.
How do I set the encoding?
http://www.php.net/manual/en/function.d ... ew-doc.php
Posted: Sat Jan 20, 2007 8:19 am
by Kieran Huggins
from a comment in the manual: libxml uses "UTF-8" internal encoding
Use
mb_convert_encoding() on your node contents to make them UTF-8 as well
(I read somewhere that
mb_convert_encoding() is faster than
utf8_encode()...)
Posted: Sat Jan 20, 2007 8:46 am
by nadavvin
I want UTF-8 is not the problem.
But I also want that it will add in the XML output:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
Posted: Sat Jan 20, 2007 8:57 am
by Kieran Huggins
two suggestions (ordered by wackiness)
1. pass the encoding as a second argument and see if it works
2. when all's said and done, do a preg_replace() on the document to add the text
Posted: Sat Jan 20, 2007 1:52 pm
by Ollie Saunders
When encoding="UTF-8" isn't present in <?xml UTF-8 encoding is assumed anyway.