function JSimpleXMLElement::getElementByPath in Ubercart 5
Get an element in the document by / separated path
Parameters
string $path The / separated path to the element:
Return value
object JSimpleXMLElement
File
- uc_store/
includes/ simplexml.php, line 583
Class
- JSimpleXMLElement
- SimpleXML Element
Code
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;
}