всем привет.
хочу сделать пхп код который бы изменял хмл файл. Нарыл кучу примеров в интернете, и ни один не работает(тестил на денвере и на хосте, который поддерживает пхп).
например вот такой пример был:
файл test.xml

Код:
<?xml version="1.0" encoding="UTF-8" ?>
<books>
<book>
<title>Антилузер</title>
<author>Илиас Меркури</author>
<pages>288</pages>
<isbn>978-5-271-19777-2</isbn>
<year>2008</year>
</book>
<book>
<title>Присягнувшие тьме</title>
<author>Жан-Кристоф Гранже</author>
<pages>848</pages>
<isbn>978-5-389-00013-1</isbn>
<year>2008</year>
</book>
<book>
<title>Евангелие от Джимми</title>
<author>Дидье Ван Ковеларт</author>
<pages>400</pages>
<isbn>978-5-98358-189-0</isbn>
<year>2008</year>
</book>
</books>
файл test.php

PHP код:
<?php
$xml = simplexml_load_file('test.xml');
$xml->book[1]->pages = 850;
$xml->asXML('test.xml');
?>
в итоге браузер выдает следующее:
Цитата:
Warning: simplexml_load_file() [function.simplexml-load-file]: test.xml:4: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xC0 0xED 0xF2 0xE8 in /home2/mrvideo/public_html/a/testxml/test.php on line 2
Warning: simplexml_load_file() [function.simplexml-load-file]: <title>Антилузер</title> in /home2/mrvideo/public_html/a/testxml/test.php on line 2
Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home2/mrvideo/public_html/a/testxml/test.php on line 2
Fatal error: Call to undefined method stdClass::asXML() in /home2/mrvideo/public_html/a/testxml/test.php on line 4
|
и аналогичные вещи со всеми примерами, которые встречал.
с пхп особо не дружу.
подскажите что я делаю не так.