note 55916 added to function.domnode-last-child

From: Date: Wed, 17 Aug 2005 18:05:02 +0000
Subject: note 55916 added to function.domnode-last-child
Groups: php.notes 
Request: Send a blank email to php-notes+get-93801@lists.php.net to get a copy of this message
How in the world do you use this function? This is what I have... $xml_file = "Forum.xml"; //on my PC I have it the the absolute path. if(!$doc = xmldocfile($xml_file)) { die("Error al abrir archivo XML."); } $root = $doc->root(); $children = $root->children(); for ($x=0; $x<sizeof($children); $x++) { $attrib = $children[$x]->attributes(); if ($children[$x]->has_child_nodes()) { echo "<tr>\n"; echo "<td>".$attrib[1]->value."</td>\n"; echo "<td>".$attrib[0]->value."</td>\n"; $cc = $children[$x]->children(); $ca = $cc[1]->attributes(); echo "<td>".$ca[0]->value."</td>\n"; } if ($children[$x]->has_child_nodes()) { echo "</tr>\n"; } } This is the XML file <?xml version="1.0" encoding="ISO-8859-1" ?> <Forum> <Thread id="20" subject="Testing" > <Article author="Name1" date="2005-08-04" > Text1 </Article> </Thread> <Thread id="24" subject="Probando múltiples artículos"> <Article author="Name2" date="2005-08-07" > Text2 </Article> <Article author="Name3" date="2005-08-08" > Text3 </Article> <Article author="Name4" date="2005-08-09" > Text1 </Article> </Thread> <Thread id="25" subject="Carne descongelada" > <Article author="Name5" date="2005-08-10" > Text4 </Article> <Article author="Name6" date="2005-08-11" > Text5 </Article> </Thread> </Forum> I need to output a table with the Subjects the ID and the Author of the LAST article (asuming the last article is the last child... I can't do it with last child... I have been trying for HOURS and I will keep trying... any ideas? if I figure it out I will post again. ---- Manual Page -- http://www.php.net/manual/en/function.domnode-last-child.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55916 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55916&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55916&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55916&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55916&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55916&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55916&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55916&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93801) next »