Gianluca
Gianluca

Reputation: 142

How to use System.Windows.Forms in Windows Phone 8.1?

I want create a very simple HTML parser application. I read lots of tutorial and lots of developer use this class: HtmlDocument. I want use this class in my app too but I am not able to add reference to System.Windows.Forms.

I try to add reference in Project > Reference but I can't find Windows.Forms. How can I fix this problem and use HtmlDocument?

I use Visual Studio 2013.

Thank you.

This is my very simple code:

namespace ParseHTML
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;
            string url = "http://www.alvolante.it/";
            download(url);
        }

        private async void download(string url)
        {
            HttpClient client = new HttpClient();
            string risposta = await client.GetStringAsync(new Uri(url)); //download html della pagina web
            HtmlDocument hc = new HtmlDocument();  //error here, missing reference or assembly?


        }

Upvotes: 0

Views: 475

Answers (1)

Dai
Dai

Reputation: 155648

You can't. WinForms is not supported nor even implemented on Windows Phone (Windows Mobile 6.5.3 released in early 2010 is the last "Windows" phone OS to support WinForms by way of the Compact Framework).

To process HTML in applications, I suggest HtmlAgilityPack instead, which provides a fault-tolerant DOM manipulation library: http://htmlagilitypack.codeplex.com

Upvotes: 1

Related Questions