Actions

API15

JSimpleXMLElement/getElementByPath

From Joomla! Documentation

< API15:JSimpleXMLElement
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Get an element in the document by / separated path

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

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

Returns

object

Defined in

libraries/joomla/utilities/simplexml.php

Importing

jimport( 'joomla.utilities.simplexml' );

Source Body

function &getElementByPath($path)
{
        $tmp    =& $this;
        $false  = false;
        $parts  = explode('/', trim($path, '/'));
 
        foreach ($parts as $node)
        {
                $found = false;
                foreach ($tmp->_children as $child)
                {
                        if ($child->_name == $node)
                        {
                                $tmp =& $child;
                                $found = true;
                                break;
                        }
                }
                if (!$found) {
                        break;
                }
        }
 
        if ($found) {
                $ref =& $tmp;
        } else {
                $ref =& $false;
        }
        return $ref;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />