有人能推荐一个在PHP中编码和解码XML的好而稳定的类吗?
编辑
在php.net上找到了这个例子,但是无法使其工作...没有返回错误信息。
$sxe = new SimpleXMLElement();
$sxe->addAttribute('type', 'documentary');
$movie = $sxe->addChild('movie');
$movie->addChild('title', 'PHP2: More Parser Stories');
$movie->addChild('plot', 'This is all about the people who make it work.');
$characters = $movie->addChild('characters');
$character = $characters->addChild('character');
$character->addChild('name', 'Mr. Parser');
$character->addChild('actor', 'John Doe');
$rating = $movie->addChild('rating', '5');
$rating->addAttribute('type', 'stars');
echo $sxe->asXML();
SimpleXMLElement::addChild()
等方法向XML对象添加新节点。 - user142162SimpleXMLElement
类。如果它说找不到该类,则需要安装它。 - user142162