Retrieves a string between two delimiters.
STREXTRACT(cSearchExpression, cBeginDelim [, cEndDelim [, nOccurrence [, nFlag]]]])
- Specifies the string to search.
- Specifies the character that delimits the beginning of cSearchExpression.
- Specifies the character that delimits the end of cSearchExpression.
- Specifies at which occurrence of cBeginDelim in cSearchExpression to start the extraction.
Specify the type of controls placed on the search. The number you specify in nFlag provides a bit-value that determines options according to the following table:
Bit Value (additive) Description
End delimiter not required. Specifies that a search, which finds no occurrence of cEndDelim, returns the contents of cSearchExpression from the cBeginDelim location.
Include the delimiters in the returned expression.
The default is a case sensitive search in which delimiters must be found (no nFlag value).
If cBeginDelim is an empty string, the search is conducted from the beginning of cSearchExpression to the first occurrence of cEndDelim. If cEndDelim is an empty string STREXTRACT(В ) returns a string from nOccurrence of cBeginDelim to the end of cSearchExpression.
CLEAR SET PATH TO (HOME(2) + 'Data\') &&Set path to the customer table USE customer && any table ?cursortoxml(0,"x",1,0,2) && Produce variable "x" that has XML of first 2 records of table ?x && show the XML xmlproc(x,0) && Parse the XML PROCEDURE xmlproc(x as String, nLev as Integer) as void LOCAL cTagName, cContents, mterm DO WHILE .t. cTagName = STREXTRACT(x,"<",">") IF LEN(cTagName) = 0 && no tag found ??' ',x && print out raw string as contents EXIT ENDIF IF RIGHT(cTagName,1) = '/' && like "<region/>" cTagName = LEFT(cTagName, LEN(cTagName)-1) cContents="" mterm = "<"+cTagName+"/>" && "<region/>" ELSE mterm = "</"+cTagName+">" && "</region>" cContents = STREXTRACT(x,"<"+cTagName+">", mterm,1,2) ENDIF ?REPLICATE(" ",nLev),nLev+1,PADR(cTagName,20) xmlproc(cContents, nLev+1) x = STREXTRACT(x, mterm) && get the rest of the xml ENDDO