original_string: public function getpath($xml, $path, $default, $istext=false, $error='') {
          foreach ($path as $index) {
              if (!isset($xml[$index])) {
                  if (!empty($error)) {
                      $this->error($error);
                      return false;
                  } else {
                      return $default;
                  }
              }
  
              $xml = $xml[$index];
          }
  
          if ($istext) {
              if (!is_string($xml)) {
                  $this->error(get_string('invalidxml', 'qformat_xml'));
              }
              $xml = trim($xml);
          }
  
          return $xml;
      }
code: public function getpath($xml, $path, $default, $istext=false, $error='') {
          foreach ($path as $index) {
              if (!isset($xml[$index])) {
                  if (!empty($error)) {
                      $this->error($error);
                      return false;
                  } else {
                      return $default;
                  }
              }
  
              $xml = $xml[$index];
          }
  
          if ($istext) {
              if (!is_string($xml)) {
                  $this->error(get_string('invalidxml', 'qformat_xml'));
              }
              $xml = trim($xml);
          }
  
          return $xml;
      }
code_tokens: public function getpath ( $ xml , $ path , $ default , $ istext = false , $ error = '' ) { foreach ( $ path as $ index ) { if ( ! isset ( $ xml [ $ index ] ) ) { if ( ! empty ( $ error ) ) { $ this -> error ( $ error ) ; return false ; } else { return $ default ; } } $ xml = $ xml [ $ index ] ; } if ( $ istext ) { if ( ! is_string ( $ xml ) ) { $ this -> error ( get_string ( 'invalidxml' , 'qformat_xml' ) ) ; } $ xml = trim ( $ xml ) ; } return $ xml ; }
docstring: return the value of a node, given a path to the node
  if it doesn't exist return the default value
  @param array xml data to read
  @param array path path to node expressed as array
  @param mixed default
  @param bool istext process as text
  @param string error if set value must exist, return false and issue message if not
  @return mixed value
docstring_tokens: return the value of a node given a path to the node if it doesn t exist return the default value