How can I get the element value from the web page in C#, with the WPF WebBrowser component?
For example I want to get this value 1.7655 from this page http://www.forexpros.com/currencies/usd-gel.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
After you call the
Navigatemethod of theWebBrowsercomponent of WPF to open a webpage, theDocumentCompletedevent arrives, and you can safely browse the content of the page (note that sometimes this event occurs multiple times). TheDocumentproperty ofWebBrowsercontains the HTML in an already processed format, called the DOM tree. Unfortunately, you cannot use this property easily, since it is only anobject. This feature has not been completed in WPF (December 2011).I would use the Winforms version of
WebBrowserinstead. You can use it in a WPF application if you embed it into aWindowsFormsHost. This class is complete: itsDocumentproperty is anHtmlDocumentobject, with aBodyproperty, which is anHtmlElement, which contains the content of the page. You can walk the DOM tree recursively to find the element you want (and read itsInnerText), or simply process the text of the whole page using Regex or an HTML parser library.