Exemple #1
0
 public static function get_relative_xpath($node)
 {
     if (@(!$node['tag'])) {
         return "";
     } else {
         if (@(!$node['children'])) {
             return $node['tag'];
         } else {
             $nodes = [];
             foreach ($node['children'] as $child) {
                 $child_xpath = Parser::get_relative_xpath($child);
                 if ($child_xpath != "") {
                     $nodes[] = $child_xpath;
                 }
                 if (count($nodes) > 0) {
                     return $node['tag'] . "[" . implode("+", $nodes) . "]";
                 } else {
                     return $node['tag'];
                 }
             }
         }
     }
 }