Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.118.184.237] |
|
Сообщ.
#1
,
|
|
|
//Building xml document... $xml_doc= new_xmldoc("1.0"); $xml_root= $xml_doc->add_root("forums"); foreach($xfr_forums as $xfr_forums_id){ $xml_forum=$xml_root->new_child("forum",""); $xml_forum->set_attribute("id",$xfr_forums_id); $xml_topics=$xml_forum->new_child("topics",""); foreach($xfr_topics as $xfr_topics_list){ if($xfr_forums_id== $xfr_topics_list['forum_id']){ $xml_topic=$xml_topics->new_child("topic",""); $xml_topic->set_attribute("id",$xfr_topics_list['tid']); $xml_topic->set_attribute("topic_name",$xfr_topics_list['title']); $xml_topic->set_attribute("topic_desc",$xfr_topics_list['description']); $xml_posts=$xml_topic->new_child("posts",""); foreach($xfr_posts as $xfr_posts_list){ if($xfr_topics_list['tid']==$xfr_posts_list['topic_id']){ $xml_post=$xml_posts->new_child("post",""); $xml_post->set_attribute("id",$xfr_posts_list['pid']); $xml_post->set_attribute("post_uid",$xfr_posts_list['author_id']); $xml_post->set_attribute("post_user_name",$xfr_posts_list['author_name']); $xml_post->set_attribute("post_date",$xfr_posts_list['post_date']); $xml_post->set_attribute("post_edit_time",$xfr_posts_list['edit_time']); $xml_post->set_attribute("post_smile",$xfr_posts_list['icon_id']); $xml_post->new_child("post_content","\"".$xfr_posts_list['post']."\""); } } } } } if($XFR_CONFIG['GzCompress']==1) print gzcompress($xml_doc->dumpmem(),$XFR_CONFIG['GzCompressLevel']); else print $xml_doc->dumpmem(); Данные выбираются из MySQL (что, в прочем, не важно) в кодировке windows-1251 1. При выводе документа вместо русских символов выводиться фигня (Насколько я понимаю функция dumpmem пытается вывести текст в UTF-8), чего я очень не хочу. Как заставить формировать документ в windows-1251? 2. Вторая проблема вытикает из первой: пары символов вместе с '&' в xml тегах вызывают ошибку интерпретации xml документа. |
Сообщ.
#2
,
|
|
|
У DomDocument есть атрибут encoding
Как вариант - можешь перекодировать свой 1251 в UTF-8: http://www.php.net/manual/en/ref.iconv.php |
Сообщ.
#3
,
|
|
|
Конвертируй его с помощью iconv
Или ещё лучше используй DOM. |