code: private function encodeRecord($record, $childName, &$xml)
      {
          foreach ($record as $key => $value)
          {
              if ($value instanceof \DateTime)
              {
                  if ($value->format('His') === '000000') {
                      $value = $value->format('m/d/Y');
                  } else {
                      $value = $value->format('Y-m-d H:i:s');
                  }
              }
  
              $keyValue = $xml->addChild($childName);
              $keyValue->addAttribute('val', $key);
  
              if(is_array($value)) {
                 $this->parseNestedValues($value, $keyValue);
              }
              else {
                  $keyValue[0] = $value;
              }
          }
      }
docs: Encodes a request record
  @param array $record
  @param string $childName XML node name
  @param SimpleXMLElement $xml