/**
 * helper function to scan xml for element with given name
 *
 * @param mixed $xml
 * @param mixed $ind
 * @param mixed $atree
 */
function findXMLelement($xml, $ind, $atree)
{
    foreach ($xml->children() as $f_gen) {
        if ($f_gen->getName() == $atree[$ind]) {
            $ind++;
            if ($ind == count($atree)) {
                return $f_gen;
            } else {
                return findXMLelement($f_gen, $ind, $atree);
            }
        }
    }
    return null;
}
Beispiel #2
0
/**
* find xml element
*
* @param mixed $xml
* @param mixed $ns
* @param mixed $name
*/
function findXMLelement($xml, $ns, $name)
{
    if ($ns) {
        $children = $xml->children($ns, true);
    } else {
        $children = $xml->children();
    }
    foreach ($children as $f_gen) {
        if ($f_gen->getName() == $name) {
            return $f_gen;
        } else {
            $res = findXMLelement($f_gen, $ns, $name);
            if ($res) {
                return $res;
            }
        }
    }
    return null;
}