Actions

API16

JSimpleXMLElement/getElementByPath

From Joomla! Documentation

< API16:JSimpleXMLElement
Revision as of 17:56, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

[Edit Descripton]

Description:JSimpleXMLElement/getElementByPath

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;
        $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;
}

[Edit See Also] SeeAlso:JSimpleXMLElement/getElementByPath

Examples

<CodeExamplesForm />