Using the Visual Studio integrated development environment and the C# programming language, we will develop a cross-platform mobile application to download the HTML content of a web page.
Information
HTML is the standard markup language for describing and designing web pages. HTML is a standard on the Internet and its rules are defined by the World Wide Web Consortium (W3C).
Launch the Visual Studio integrated development environment.
Create a new project: Visual C# > Cross-Platform > Mobile App (Xamarin.Forms).
Name the project: HTML Downloader 2.0.
Install the additional package for the app from: Tools > NuGet Package Manager > Package Manager Console, by running the following command in the console:
PM> Install-Package AngleSharp -Version 0.16.1
MainPage.xaml
The MainPage.xaml file contains the source code for the application's user interface design and is written in XAML. Copy (Ctrl+C) and paste (Ctrl+V) the fragment below into your application.
<!-- User Interface (UI): HTML Downloader 2.0 --><StackLayoutPadding="20"BackgroundColor="LightCoral"><!-- Title --><LabelText="HTML Downloader 2.0"FontSize="Large"/><!-- URL --><LabelText="URL"FontSize="Large"/><Entryx:Name="URL"Text="https://www.minchev.eu"/><ButtonText="Download"Clicked="OnButtonClicked"/><!-- HTML --><ScrollView><Labelx:Name="HTML"/></ScrollView></StackLayout>
MainPage.xaml.cs
The MainPage.xaml.cs file contains the source code for the application's business logic and is written in C#. Copy (Ctrl+C) and paste (Ctrl+V) the fragment below into your application.
Demo
Run the application from the menu: Debug > Start Debugging or by pressing the F5 key.
Fig. 2.61 Testing the cross-platform mobile application for downloading the HTML content of a web page - Android Emulator 11 (API 30).