API15:JSimpleXMLElement/getElementByPath
From Joomla! Documentation
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
Code Examples