Get Text From Web App Into String

I was wondering is it possible to get a line of text that is displayed from a xojo web app in a html viewer into a string you could use in a desktop app? Thanks.

Could you elaborate more? Do you mean communication between the web browser and your desktop app, or are you just serving data from Xojo Web that you want to get with a HTTP Socket?

Sure, I have a xojo web app that I am displaying in an html viewer in a desktop app. I would like to grab some of the text it is displaying and use it in my desktop app as a string. Thanks.

I tried using a HTTP socket to get the source code into a text area but all I get is a single character.

Dim socket1 As New HTTPSocket Dim data As String = socket1.Get("", 80) TextArea1.Text = data

Web page displays just fine in an HTML Viewer.

I added a DocumentComplete event to my html viewer and added this code:

me.ExecuteJavaScript "window.status = document.getElementsByTagName('html')[0].innerHTML;"

Then in StatusChanged event I added this code:

TextArea1.text = newStatus

But I get an error page source instead of the web app source I want.


The application has gone off-line. Please try again later.

This application has encountered an error and cannot continue.

Some fatal error

Please describe what you were doing right before the error occurred:

Send Do Not Send

Javascript must be enabled to access this page.

To turn Javascript on, please refer to your browser settings window.


I saved the source code of the web app loaded into a browser instead and looked for the div ID of the exact html text I’m looking for and tried something like this in DocumentComplete:

me.ExecuteJavaScript "window.status = document.getElementById('MBWjUZyu').innerHTML;"

Still nothing. @Tim Parnell Any ideas? Thanks.

The div ID will change for each session of the app, you’ll have to identify it another way.

DocumentComplete will trigger before that control is available because DocumentComplete will trigger once the basic webpage is loaded, and Xojo Web apps are dynamic - the rest of the controls will load later.

If you are able to control the contents you are looking for you could put it inside your own div and name it accordingly. You would then be able to use the window.status method.

What exactly are you trying to get out of the web app? Is it possible to get another way?

@Tim Parnell

Yes it’s possible to get it another way. This was just going to be a temporary solution. Thank you for your help I appreciate it.