|
Previous Top Next |
Prototype: | (STRING pBegin, STRING pEnd, STRING pSearchString,<Long pBeginPos>, <Long pEndBeginPos>, BYTE pCaseSensitive=FALSE),STRING |
pBegin | The string to search for to mark the beginning of the new string. The new string starts in the character position after the pBegin is found. |
pEnd | The string to search for to mark the end of the new string. The new string ends in the character position before the pEnd is found. |
pSearchString | The string to search in. |
pBeginPos | Optionally specify where to start searching in pSearchString to find the beginning position |
pEndBeginPos | Optionally specify where to start searching in pSearchString to find the beginning of the end position. |
pCaseSensitive | Optionally specify if the search should be case sensitive. Defaults to false (i.e. NOT case sensitive - all comparisons are done using UPPER() |
Returns | Returns the string found between pBegin and pEnd or empty string if either or neither was found or if the end position is lower than the beginning position. |
This method takes a string and then searches for a beginning and end strings in it and returns the string between those two strings. This is very handy for example to extract data from for example html or xml strings.
Example:
GetServiceXMLError PROCEDURE(STRING pXML)
ITS ITStringClass
Err_Value CSTRING(101)
Err_Text CSTRING(1025)
CODE
!! (STRING pXML),STRING
IF INSTRING('<SOAP:REASON>',UPPER(pXML),1,1)
Err_Value = ITS.GetStringBetween('<soap:Value>', '</soap:Value>',pXML)
Err_Text = ITS.GetStringBetween('<soap:Text xml:lang="en">','</soap:Text>', pXML)
ITS.ODS('Value: ' & Err_Value)
ITS.ODS('Reason: ' & Err_Text)
ELSIF INSTRING('<FAULTCODE>',UPPER(pXML),1,1)
Err_Value = ITS.GetStringBetween('<faultcode>', '</faultcode>', pXML)
Err_Text = ITS.GetStringBetween('<faultstring>', '</faultstring>', pXML)
ITS.ODS('Fault Code: ' & Err_Value)
ITS.ODS('Fault String: ' & Err_Text)
END
RETURN(Err_Text)
See also: