‎04-07-2012 06:54 PM
Hello Everyone,
I've searched around the internet for a couple of hours and could not find anything related to what I'm trying to do. I wrote a HTML document that collects data from a user and stores it in a javascript array. This array is then joined together and stored as a string in a document which is hidden. Originally, I was going to transfer this string to a program I wrote in C#, but now I am using LabVIEW.
I cannot find a way to access the data that is in this hidden document. I'm using the IWebBrowser2 block to embed my HTML code in my VI. Any help would be greatly appreciated. Thank you for your time!
‎04-08-2012 06:42 PM
Why are you using LabVIEW for what is essentially a web application?
‎04-09-2012 02:33 PM
The purpose of the instrument is certainly not a web application. The VI is a mission control suite which communicates with an autonomous UAV, which features both telemetry and telecommand. A portion of the VI must obtain GPS cordinate somehow and plot the location of the UAV. An HTML document was already written which uses javascript and Google Maps API to offer a custom polished mapping solution. I just need to access this array.
‎04-09-2012 03:44 PM
If you were doing this in C# instead of LabVIEW, would you still be using the web browser? If so, and you know how you would do it in C#, we might be able to help translate that into LabVIEW. However, I have no idea how you would get data out of a Javascript array and into another application. If the data you need is stored as a named item (contents of a text field, for example) then you can get access by retrieving the value of that HTML element, for example as shown here:
http://forums.ni.com/t5/LabVIEW/Controlling-a-web-page-from-Labview/m-p/1700284#M602002
‎04-09-2012 04:09 PM - edited ‎04-09-2012 04:10 PM
nathand,
Thank you for your reply. In C#, I was still using an embedded web browser object to load the HTML document, so yes. I have two simple lines of code that allowed me to access the data. I actually took the javascript array, joined the data using a delimiter, and stuffed the data as a string into a hidden field in the HTML document called "hiddenfield1". I accessed the hidden field in C# by taking the hidden field's value. Here is the code:
System.Windows.Forms.HtmlElement hidden = webBrowser1.Document.GetElementById("hiddenfield1");
List<latlng> data = formharvest.extract(hidden.GetAttribute("value"));
"formharvest" is a special class I made which formats the data nicely and stuff it into another list I made called latling (latitude longitude).
But for the life of me, I cannot find a way to reproduce my C# code in LabVIEW. I will take a look at the links you provided me as soon as I'm out of class. Thanks again!