JSimpleXMLElement/getElementByPath
From Joomla! Documentation
< API15:JSimpleXMLElement
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
The "API15" 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
Template:Description:JSimpleXMLElement/getElementByPath
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;
$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;
}
[Edit See Also] Template:SeeAlso:JSimpleXMLElement/getElementByPath
Examples[edit]
<CodeExamplesForm />