It is most correct to check the already received XML for the tag.
If Pos('<DELIVERY_DATE>', XmlResponse) > 0 then // значит тэг есть. ... else // тэга нет.
PS I saw the condition without creating an XML document . Counterquestion; and why? Why complicate things? Why poke around in a SOAP envelope and pile up extra lines of code?
For each task there is an elegant solution. And this one too. The grace here will be to find the tag is already in the answer . In this case, the XML file itself can not be rushed to write to the disk, and tag search operations can be performed in memory.
UPDATE
I think the problem may be in a variable that is declared as var . In this case, I would advise you to declare the intermediate variable var s: string and assign it the value XMLNode.Xml . Thus, the XML text is simply copied to the variable s and further manipulations can be made with it.
UPDATE 2
As it turned out in the chat, you need to correctly check the presence of the <DELIVERY_DATE> element, without causing exceptions and without resorting to direct parsing of lines, which is unwise in this situation. Thus, the methods proposed above are attempts to give an answer to an incorrectly formulated question .
In order to correctly check the presence of an element through MSXMLDOM, you need to use the FindNode() method which is available for the IXMLNodeList collection. In the code, it will look like this (for clarity, I used with..do ):
with FromServ.get_buyer_waybillsResult.XMLNode.ChildNodes[i] do //сначала обязательно проверим наличие элемента //чтобы потом не попытаться обратиться к неициализированному объекту и не вызвать AV if ChildNodes.FindNode('DELIVERY_DATE') = nil then //элемента не существует ShowMessage('There is no DELIVERY_DATE element in this Waybill!') else //элемент существует begin ... end;
If you look at the nesting hierarchy of objects, then everything looks very logical:
XMLNode in the code above means the entire Waybills collection (i.e., <WAYBILL_LIST> )- Next, we run in a loop through all the child nodes of
WAYBILL , “look in” them and look for the elements we need in their child nodes ( ChildNodes ) - Finding the desired item is done via
FindNode('DELIVERY_DATE') . If the item is not found, then the value will be nil .
Then everything is very easy.
And on dessert: WHY DID POS () NOT WORK?
Because all sorts of things like ChildValues['DELIVERY_DATE'] do not return a string , but System.OleVariant which cannot be implicitly converted to a string. For this reason, an exception was thrown.
UPDATE 3
Here is a screen of fully working code. Which fulfills the tag "non-spawning" and gives it to the log below.

UPDATE 4
Here is the code that does not just answer the question, but also solves the specific problem of the author-programmer. Which he must decide himself, not us.
//показываем что вне зависимости от наличия/отсутствия тэга //мы будем добавлять записи в DataGrid CDSGetBuyerWaybills.Append; if FromServ.get_buyer_waybillsResult.XMLNode.ChildNodes[i].ChildNodes.FindNode('DELIVERY_DATE') = nil then begin //логируем информацию о том, что WB без DELIVERY_DATE Memo.Lines.Add ('There is no DELIVERY_DATE node in this WB with ID=' + IntToStr(i)); //произвольно устанавливаем значение переменной strDelivery_Date strDelivery_Date := 'active'; end else //иначе!!! (если тэг есть) begin strDelivery_Date:=FromServ.get_buyer_waybillsResult.XMLNode.ChildNodes[i].ChildValues['DELIVERY_DATE']; strYear:=copy(strDelivery_Date,1,4); //за такое преобразование даты strMonth:=copy(strDelivery_Date,6,2); //нужно нещадно бить розгами! strDay:=copy(strDelivery_Date,9,2); strDelivery_Date:=strDay+FormatSettings.DateSeparator+strMonth+FormatSettings.DateSeparator+strYear; end; //теперь, когда все условия проверены и параметры установлены //начинаем запиливать значения в DataGrid: CDSGetBuyerWaybills.FieldByName('ID').AsString := FromServ.get_buyer_waybillsResult.XMLNode.ChildNodes[i].ChildValues['WAYBILL_NUMBER']; CDSGetBuyerWaybills.FieldByName('amount').AsString :=VarToStrDef(FromServ.get_buyer_waybillsResult.XMLNode.ChildNodes[i].ChildValues['FULL_AMOUNT'], ''); CDSGetBuyerWaybills.FieldByName('seller').AsString := VarToStrDef(FromServ.get_buyer_waybillsResult.XMLNode.ChildNodes[i].ChildValues['SELLER_NAME'], ''); CDSGetBuyerWaybills.FieldByName('create_date').AsString:=strCreate_Date; CDSGetBuyerWaybills.FieldByName('delivery_date').AsString:=strDelivery_Date; CDSGetBuyerWaybills.FieldByName('activate_date').AsString:=strActivate_Date; //в самом конце проверяем статус if FromServ.get_buyer_waybillsResult.XMLNode.ChildNodes[i].ChildValues['STATUS']=1 then CDSGetBuyerWaybills.FieldByName('status').AsString:='active' else CDSGetBuyerWaybills.FieldByName('status').AsString:='ended'; //и наконец постим все это в базу CDSGetBuyerWaybills.Post;