This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.
This version is copyright and may only be used for local testing purposes. It may not be distributed.
Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.
Description
Returns a string delimited by StrDelim_1 and and StrDelim_2
Syntax
s = GRAB$(StringExpression, StrDelim_1, StrDelim_2 [, Index])
Returns
String
Parameters
Name |
Type |
Optional |
Meaning |
StringExpression |
String |
No |
The string to parse. |
StrDelim_1 |
String |
No |
First delimiter |
StrDelim_2 |
String |
No |
Second delimiter |
Index |
Numeric |
Yes |
The delimited field number to return. If omitted, 1 is assumed. |
Remarks
Restrictions
See also
Examples
#MinVersion 1.10.4
uses "Console"
PrintL "-----------------------------------------------------------------" in %CCOLOR_FYELLOW
PrintL "---Load XML from https://www.w3schools.com/xml/cd_catalog.xml ---" in %CCOLOR_FYELLOW
PrintL "---Using winhttp.winhttprequest.5.1 COM Object ---" in %CCOLOR_FYELLOW
PrintL "---And parse string buffer (XML) using GRAB$ ---" in %CCOLOR_FYELLOW
PrintL "-----------------------------------------------------------------" in %CCOLOR_FYELLOW
PrintL "---WinHttpRequest object reference: ---" in %CCOLOR_FYELLOW
PrintL "---https://msdn.microsoft.com/en-us/library/windows/desktop/aa384106(v=vs.85).aspx" in %CCOLOR_FYELLOW
PrintL "-----------------------------------------------------------------" in %CCOLOR_FYELLOW
iDispatch oHTTP
String sXML
string sCD
string sTitle
long lCDIndex
printl "Creating winhttp.winhttprequest.5.1 object ..."
ohttp = NewCom("winhttp.winhttprequest.5.1")
if IsComObject(oHttp) then
printl "Object creation was ok"
printl "Now Getting XML ..." in %CCOLOR_FYELLOW
'---Open connection, send request, get response
oHTTP.Open("GET", "https://www.w3schools.com/xml/cd_catalog.xml")
oHTTP.Send
sXML = oHTTP.Responsetext
PrintL "All done." in %CCOLOR_FYELLOW
PrintL "---Press a key to print XMl content---" in %CCOLOR_FYELLOW
WaitKey
'---Print XML content
printl sXML
printl "---Now Parsing XML using GRAB$..." in %CCOLOR_FYELLOW
PrintL "---Press a key to start---" in %CCOLOR_FYELLOW
WaitKey
'---Loop till we have a <CD> node
lCDIndex = 1
Do
'---Grab all <CD></CD> nodes
sCD = grab$(sXML, "<CD>", "</CD>", lCDIndex)
if len(sCD) Then
'---From <CD> node get <TITLE> node
sTitle = grab$(sCD, "<TITLE>", "</TITLE>")
printl lCDIndex, "CD Title:", sTitle in %CCOLOR_FCYAN
printl $tab, "<CD> node content" in %CCOLOR_FLIGHTMAGENTA
printl sCD
incr lCDIndex
end If
loop while len(sCD)
'---Release object
oHttp = nothing
Else
PrintL "Error creating winhttprequest.5.1 COM Object" in %CCOLOR_FLIGHTRED
end if
PrintL "---All done, press a key to end---" in %CCOLOR_FYELLOW
WaitKey