API16

JSimpleXMLElement/getElementByPath

From Joomla! Documentation

< API16:JSimpleXMLElement

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Get an element in the document by / separated path



Syntax[edit]

getElementByPath($path)
Parameter Name Default Value Description
$path $path The / separated path to the element

Returns[edit]

object

Defined in[edit]

libraries/joomla/utilities/simplexml.php

Importing[edit]

jimport( 'joomla.utilities.simplexml' );

Source Body[edit]

function getElementByPath($path)
{
        $tmp    = &$this;
        $parts  = explode('/', trim($path, '/'));

        foreach ($parts as $node)
        {
                $found = false;
                foreach ($tmp->_children as $child)
                {
                        if (strtoupper($child->_name) == strtoupper($node))
                        {
                                $tmp = &$child;
                                $found = true;
                                break;
                        }
                }
                if (!$found) {
                        break;
                }
        }

        if ($found) {
                return $tmp;
        }

        return false;
}



Examples[edit]

Code Examples[edit]