XML encode/decode class in PHP -
can suggest , stable class encode , decode xml in php?
edit
found example on php.net, can't make work.. no error msgs returned
$sxe = new simplexmlelement(); $sxe->addattribute('type', 'documentary'); $movie = $sxe->addchild('movie'); $movie->addchild('title', 'php2: more parser stories'); $movie->addchild('plot', 'this people make 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();
simplexml easiest. example:
<root> <node> <sub>text</sub> </node> </root>
$xml = new simplexmlelement('xml_file.xml', 0, true); echo $xml->node->sub; // displays "text"
edit:
in response code isn't working, need include root node in initiation of class:
$sxe = new simplexmlelement('<root />');
Comments
Post a Comment