note 84641 deleted from domdocument.registernodeclass by bjori
| From: | bjori@php.net | Date: | Tue, 28 Oct 2008 09:23:33 +0000 |
| Subject: | note 84641 deleted from domdocument.registernodeclass by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145854@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
If you want to get child nodes of some node, try something like this:
<?php
// check
$doc = new DomDocument();
// load XML file
$doc->loadXML($items);
// Now loop through and get root
// get those we need (all of them actually)
$Elements = $doc->getElementsByTagName("item");
// loop through
foreach($Elements as $elem)
{
// check if the element is a root one
if($elem->parentNode->getAttribute("link"))
{}
else
{
// if it IS then check if it has child nodes
if($elem->hasChildNodes())
{
// if it has them just got only child nodes
$Children = $elem->getElementsByTagName("item");
// do whatever you want with your children
}
}
}
?>