original_string: public function getCmdResultFromXml($xml, $parentTag = 'sh') {
          $this->error = '';
          
          $xmlobj = simplexml_load_string($xml);
          if (!$xmlobj instanceof \SimpleXMLElement) {
              /*bad xml returned*/
              $this->error = "Can't read output xml";
              error_log($xml, 3, '/tmp/bad.xml');
              
              return false;
          }
          
          $retval = true; // assume OK unless error found. Was false, but sh doesn't return success flag.
          $params = $xmlobj->xpath("/script/$parentTag");
          
          foreach ($params as $simpleXMLElement) {
              // Note: there may be multiple ->error tags
              if (isset($simpleXMLElement->error)) {//*** error
                  
                  // newer way in XMLSERVICE 
                  ///bookstore/book[last()]
                  
                  // get last joblogscan/joblogrec nested tags in the XML section. Returned as one-element array. function 'current' returns the one element.
                  $lastJoblogTag = current($simpleXMLElement->xpath("joblogscan/joblogrec[last()]"));
                  
                  // if last job log tag contained a real CPF-style code, of length 7 (e.g. CPF1234), parsed for us.
                  if ($lastJoblogTag && isset($lastJoblogTag->jobcpf) && (strlen($lastJoblogTag->jobcpf) == 7)) {
                      $this->cpfErr = (string) $lastJoblogTag->jobcpf;
                      $this->error = $this->cpfErr; // ->error has ambiguous meaning. Include for backward compatibility.
                      
                      $this->errorText = (string) $lastJoblogTag->jobtext;
                  
                      $retval = false;
                      break;
                  }
                  
                  /**
                   * <joblogscan>
                   * <joblogrec>
                   * <jobcpf>CPF1124</jobcpf>
                   * <jobtime><![CDATA[10/11/12  19:33:54.102423]]></jobtime>
                   * <jobtext><![CDATA[Job 127257/ASEIDEN/XTOOLKIT started on 10/11/12 at Job 127257/ASEIDEN/XTOOLKIT submitted.]]></jobtext>
                   * </joblogrec>
                   * <joblogrec>
                   * <jobcpf>*NONE</jobcpf>
                   * <jobtime><![CDATA[10/11/12  19:33:54.102423]]></jobtime>
                   * <jobtext><![CDATA[CALL PGM(XMLSERVICE/XMLSERVICE) PARM('/tmp/ASEIDEN_abc')]]></jobtext>
                   * </joblogrec>
                   * <joblogrec>
                   * <jobcpf>CPF3142</jobcpf>
                   * <jobtime><![CDATA[10/11/12  19:33:54.102423]]></jobtime>
                   * <jobtext><![CDATA[PLUGILE ILECMDEXC 5116 File NONEXIST in library *LIBL not found.]]></jobtext>
                   * </joblogrec>
                   * </joblogscan>
                   */
                  // xpath(joblogscan/joblogrec[last()])
                  // then ->jobcpf and ->jobtext
                  
                  // Note: there may be multiple ->error tags
                  
                  // As of XMLSERVICE 1.60:
                  // array element[0] is probably the *** error text.
                  // array element[1] may be the CPF code (not likely).
                  if (isset($simpleXMLElement->error[1])) {
                      $this->error = (string) $simpleXMLElement->error[1];
                  } else {
                      $this->error = "Command execute failed.";
                  }
                  
                  //$err = (string )$simpleXMLElement->error;
                  // there's an error code of some kind. use it.
                  // A change: get rid of standard msg. Only return the err, which may be a CPF.
                  //$this->error = "Command execute failed. ".$err;
                  
                  $retval = false;
                  break;
              }
              
              // Older style. Now, *** error appears in ->error tag
              if (strstr(((string)$simpleXMLElement),"*** error")){
                  // this message is a generic failure so it's OK.
                  $this->error = "Command execute failed. ";
                  $retval = false;
                  break;
              }
              
              // in the case of interactive commands, there may be no "success" msg.
              if (isset($simpleXMLElement->success)) {
                  $retval = true;
                  break;
              }
              
              // Older style. Now, +++ success appears in ->success tag
              if (strstr(((string)$simpleXMLElement),"+++ success")) {
                  $retval = true;
                  break;
              }
          }
          
          return $retval;
      }
code: public function getCmdResultFromXml($xml, $parentTag = 'sh') {
          $this->error = '';
          
          $xmlobj = simplexml_load_string($xml);
          if (!$xmlobj instanceof \SimpleXMLElement) {
              /*bad xml returned*/
              $this->error = "Can't read output xml";
              error_log($xml, 3, '/tmp/bad.xml');
              
              return false;
          }
          
          $retval = true; // assume OK unless error found. Was false, but sh doesn't return success flag.
          $params = $xmlobj->xpath("/script/$parentTag");
          
          foreach ($params as $simpleXMLElement) {
              // Note: there may be multiple ->error tags
              if (isset($simpleXMLElement->error)) {//*** error
                  
                  // newer way in XMLSERVICE 
                  ///bookstore/book[last()]
                  
                  // get last joblogscan/joblogrec nested tags in the XML section. Returned as one-element array. function 'current' returns the one element.
                  $lastJoblogTag = current($simpleXMLElement->xpath("joblogscan/joblogrec[last()]"));
                  
                  // if last job log tag contained a real CPF-style code, of length 7 (e.g. CPF1234), parsed for us.
                  if ($lastJoblogTag && isset($lastJoblogTag->jobcpf) && (strlen($lastJoblogTag->jobcpf) == 7)) {
                      $this->cpfErr = (string) $lastJoblogTag->jobcpf;
                      $this->error = $this->cpfErr; // ->error has ambiguous meaning. Include for backward compatibility.
                      
                      $this->errorText = (string) $lastJoblogTag->jobtext;
                  
                      $retval = false;
                      break;
                  }
                  
                  /**
                   * <joblogscan>
                   * <joblogrec>
                   * <jobcpf>CPF1124</jobcpf>
                   * <jobtime><![CDATA[10/11/12  19:33:54.102423]]></jobtime>
                   * <jobtext><![CDATA[Job 127257/ASEIDEN/XTOOLKIT started on 10/11/12 at Job 127257/ASEIDEN/XTOOLKIT submitted.]]></jobtext>
                   * </joblogrec>
                   * <joblogrec>
                   * <jobcpf>*NONE</jobcpf>
                   * <jobtime><![CDATA[10/11/12  19:33:54.102423]]></jobtime>
                   * <jobtext><![CDATA[CALL PGM(XMLSERVICE/XMLSERVICE) PARM('/tmp/ASEIDEN_abc')]]></jobtext>
                   * </joblogrec>
                   * <joblogrec>
                   * <jobcpf>CPF3142</jobcpf>
                   * <jobtime><![CDATA[10/11/12  19:33:54.102423]]></jobtime>
                   * <jobtext><![CDATA[PLUGILE ILECMDEXC 5116 File NONEXIST in library *LIBL not found.]]></jobtext>
                   * </joblogrec>
                   * </joblogscan>
                   */
                  // xpath(joblogscan/joblogrec[last()])
                  // then ->jobcpf and ->jobtext
                  
                  // Note: there may be multiple ->error tags
                  
                  // As of XMLSERVICE 1.60:
                  // array element[0] is probably the *** error text.
                  // array element[1] may be the CPF code (not likely).
                  if (isset($simpleXMLElement->error[1])) {
                      $this->error = (string) $simpleXMLElement->error[1];
                  } else {
                      $this->error = "Command execute failed.";
                  }
                  
                  //$err = (string )$simpleXMLElement->error;
                  // there's an error code of some kind. use it.
                  // A change: get rid of standard msg. Only return the err, which may be a CPF.
                  //$this->error = "Command execute failed. ".$err;
                  
                  $retval = false;
                  break;
              }
              
              // Older style. Now, *** error appears in ->error tag
              if (strstr(((string)$simpleXMLElement),"*** error")){
                  // this message is a generic failure so it's OK.
                  $this->error = "Command execute failed. ";
                  $retval = false;
                  break;
              }
              
              // in the case of interactive commands, there may be no "success" msg.
              if (isset($simpleXMLElement->success)) {
                  $retval = true;
                  break;
              }
              
              // Older style. Now, +++ success appears in ->success tag
              if (strstr(((string)$simpleXMLElement),"+++ success")) {
                  $retval = true;
                  break;
              }
          }
          
          return $retval;
      }
code_tokens: public function getCmdResultFromXml ( $ xml , $ parentTag = 'sh' ) { $ this -> error = '' ; $ xmlobj = simplexml_load_string ( $ xml ) ; if ( ! $ xmlobj instanceof \ SimpleXMLElement ) { /*bad xml returned*/ $ this -> error = "Can't read output xml" ; error_log ( $ xml , 3 , '/tmp/bad.xml' ) ; return false ; } $ retval = true ; // assume OK unless error found. Was false, but sh doesn't return success flag.
   $ params = $ xmlobj -> xpath ( "/script/$parentTag" ) ; foreach ( $ params as $ simpleXMLElement ) { // Note: there may be multiple ->error tags
   if ( isset ( $ simpleXMLElement -> error ) ) { //*** error
   // newer way in XMLSERVICE 
   ///bookstore/book[last()]
   // get last joblogscan/joblogrec nested tags in the XML section. Returned as one-element array. function 'current' returns the one element.
   $ lastJoblogTag = current ( $ simpleXMLElement -> xpath ( "joblogscan/joblogrec[last()]" ) ) ; // if last job log tag contained a real CPF-style code, of length 7 (e.g. CPF1234), parsed for us.
   if ( $ lastJoblogTag && isset ( $ lastJoblogTag -> jobcpf ) && ( strlen ( $ lastJoblogTag -> jobcpf ) == 7 ) ) { $ this -> cpfErr = ( string ) $ lastJoblogTag -> jobcpf ; $ this -> error = $ this -> cpfErr ; // ->error has ambiguous meaning. Include for backward compatibility.
   $ this -> errorText = ( string ) $ lastJoblogTag -> jobtext ; $ retval = false ; break ; } /**
                   * <joblogscan>
                   * <joblogrec>
                   * <jobcpf>CPF1124</jobcpf>
                   * <jobtime><![CDATA[10/11/12  19:33:54.102423]]></jobtime>
                   * <jobtext><![CDATA[Job 127257/ASEIDEN/XTOOLKIT started on 10/11/12 at Job 127257/ASEIDEN/XTOOLKIT submitted.]]></jobtext>
                   * </joblogrec>
                   * <joblogrec>
                   * <jobcpf>*NONE</jobcpf>
                   * <jobtime><![CDATA[10/11/12  19:33:54.102423]]></jobtime>
                   * <jobtext><![CDATA[CALL PGM(XMLSERVICE/XMLSERVICE) PARM('/tmp/ASEIDEN_abc')]]></jobtext>
                   * </joblogrec>
                   * <joblogrec>
                   * <jobcpf>CPF3142</jobcpf>
                   * <jobtime><![CDATA[10/11/12  19:33:54.102423]]></jobtime>
                   * <jobtext><![CDATA[PLUGILE ILECMDEXC 5116 File NONEXIST in library *LIBL not found.]]></jobtext>
                   * </joblogrec>
                   * </joblogscan>
                   */ // xpath(joblogscan/joblogrec[last()])
   // then ->jobcpf and ->jobtext
   // Note: there may be multiple ->error tags
   // As of XMLSERVICE 1.60:
   // array element[0] is probably the *** error text.
   // array element[1] may be the CPF code (not likely).
   if ( isset ( $ simpleXMLElement -> error [ 1 ] ) ) { $ this -> error = ( string ) $ simpleXMLElement -> error [ 1 ] ; } else { $ this -> error = "Command execute failed." ; } //$err = (string )$simpleXMLElement->error;
   // there's an error code of some kind. use it.
   // A change: get rid of standard msg. Only return the err, which may be a CPF.
   //$this->error = "Command execute failed. ".$err;
   $ retval = false ; break ; } // Older style. Now, *** error appears in ->error tag
   if ( strstr ( ( ( string ) $ simpleXMLElement ) , "*** error" ) ) { // this message is a generic failure so it's OK.
   $ this -> error = "Command execute failed. " ; $ retval = false ; break ; } // in the case of interactive commands, there may be no "success" msg.
   if ( isset ( $ simpleXMLElement -> success ) ) { $ retval = true ; break ; } // Older style. Now, +++ success appears in ->success tag
   if ( strstr ( ( ( string ) $ simpleXMLElement ) , "+++ success" ) ) { $ retval = true ; break ; } } return $ retval ; }
docstring: gets any error code and sets it in toolkit.
  returns true or false depending on interpretation of status
  
  @param $xml
  @param string $parentTag
  @return bool
docstring_tokens: gets any error code and sets it in toolkit . returns true or false depending on interpretation of status