1 (edited by sibprogsistem 2018-11-24 19:42:09)

Topic: parser

function xmlparesr (sender, w: string): string;
var
    sl: TStringList;
    s, sRow, sstatus: string;
    iPos1, iPos2, iOffset: integer;
begin
     sl := TStringList.Create;
     sl.text:=sender;
     iOffset := 1;
     iPos1 := 1;

     try
     if w = 'epochta' then  begin
     while true do
     begin
         iPos1 := PosEx('<RESPONSE>', sl.Text, iOffset);
         if iPos1=0 then break;

         iPos2 := PosEx('</RESPONSE>', sl.Text, iOffset);
         iOffset := iPos2+1;

         sRow := Copy(sl.Text, iPos1, iPos2-iPos1);

        sstatus := Copy(sRow, Pos('<status>', sRow)+Length('<status>') , Pos('</status>', sRow)-Pos('<status>', sRow)-Length('<status>'));
    end;
      if sstatus= '-1' then result:='Неправильный логин и/или пароль' else
      if sstatus= '-2' then result:='Неправильный формат XML' else
      if sstatus= '-3' then result:='Недостаточно кредитов на аккаунте пользователя ' else
      if sstatus= '-4' then result:='Нет верных номеров получателей' else
      if sstatus= '-5' then result:='Неверный текст' else
      if sstatus= '-7' then result:='Ошибка в имени отправителя ' else
      if sstatus= '1'  then result:='Сообщение принято!';
    end;
    if w = 'turbosms' then  begin
       s:=sl.text;
       Delete(s, Length(s) -2 , 3);
       if s ='Не достаточно параметров для выполнения функции' then result:='Неправильный логин и/или пароль ';
    end;
    if w = 'Clickatel' then  begin

    end;
     finally
     sl.Free;
   end;
end;

в общем обноружил,что при ответе от turbosms в конце текста есть какие-то символы, сделалтак

Delete(s, Length(s) -2 , 3);

и все заработало