I am newbie in Xojo and I’m trying to do a simpler app. I have several values in a listbox (for example: P02768, P02647 and P49840). I would like to load this webpage in the background,
Then I would like to get the source-code from each results webpage, parse two values “protein name” and “Gene” for each one (in batch), as in this example:
The answer is, yes, it’s all possible, but you have to be more specific about which part confuses you. If you ask specific questions, you’ll most likely get more responses.
Then save the resulting string in some format that suits your preferred way of parsing, such as the XMLDocument that Tim mentioned. For similar tasks I have used array = string.split(EndOfLine) to get an array that can be looped through and searched.
Also, there is a “Preview First 10” link in the download button that you might be able to manipulate to get multiple items at once in a format that is easier to work with.
finally I have followed the recommendations from Aaron and Tim and I have used HTTPSocket.Get and Instr() to do my app. To help other newbies in Xojo. I have used this method to parse the text from HTML obtained:
Method: ParseData (theText As String, theStartTag As String, theEndTag As String)
[code] Dim theStartPos As Integer
Dim theEndPos As Integer
Dim theLengthToKeep As Integer
Dim theResult As String
FileMaker doesn’t have built-in regular expressions, although you can certainly add a plugin for that. Xojo does, and you should take advantage. I’d recommend this:
theStartTag = "\\Q" + theStartTag.ReplaceAllB( "\\E", "\\\\EE\\Q" ) + "\\E"
theEndTag = "\\Q" + theEndTag.ReplaceAllB( "\\E", "\\\\EE\\Q" ) + "\\E"
dim rx as new RegEx
rx.Options.Greedy = false
rx.SearchPattern = theStartTag + "([\\s\\S]*)" + theEndTag
dim theResult as string
dim match as RegExMatch = rx.Search( theText )
if match <> nil then
theResult = match.SubExpressionString( 1 )
end if
return theResult
The encoding of theStartTag and theEndTag is safely put “\Q” and “\E” around the text. That tells the regex engine to take the text literally even if you’ve included symbols that would otherwise mean something like “*” or parens.
Thank you very much Kem. That’s true, Xojo is very powerful and this is an example. I have used your code and It works very well. I don’t understand very well the theStartTag and theEndTag code at the beginning because I haven’t enough knowledge of regular expressions but slowly.