php dom: rather newbie question
i've only started tinkering xml plan php, i've stumbled something unexpected. here's xml i'm controlling exam input:
<list>
<activity1> controlling </activity1>
<activity2> swimming </activity2>
<activity3> soccer </activity3>
</list>
now, i awaiting php formula cost 'activity1':
$xmldoc = new domdocument();
$xmldoc->load('file.xml');
//the line next $root <list> node
$root = $xmldoc->firstchild;
//the line next $cnode initial child
//of <list> node, <activity1>
$cnode = $root->firstchild;
//this should cost 'activity1'
echo 'element name: ' . $cnode->nodename;
instead, formula outputs #text. i repair inserting new line code, before duplicate node name:
$cnode = $cnode->nextsibling;
now, i have approaching imitation 'activity2' instead, nonetheless duplicate 'activity1'. going on?
Comments
Post a Comment