SlideShare a Scribd company logo
1 of 18
HTML Parsing in FLUTTER for Android / iOS
Development
The HTML parser is the structured markup processing tool defining the
HTML Parser class. It is often accessed to parse HTML files. Parsing is to
resolve into component parts and then describe their syntactic roles.
In general, parsing analyzes the String of the symbols in computer or
natural languages. When speaking about HTML parsing, it takes the
HTML code and extracts the relevant information, such as the page’s
title, headings, paragraphs, links, bold text, and much more.
Keep reading this article to learn much about HTML parsing in Flutter
for android or iOS platforms! If you need professional assistance, do
not hesitate to contact the reputable and trustworthy Flutter app
development company.
Introduction to flutter HTML
Flutter is an open-source, cross-platform mobile app development
framework. It is highly compatible with the present web rendering
technologies such as HTML, JavaScript, and CSS.
Therefore, it is a perfect platform for web and mobile app
development. With the help of Flutter developers, you can compile the
existing code into the client experience, implant it into the browser and
finally deploy it to any web server.
When you build the application with Flutter and need to render some
HTML content, you can do it easily by accessing the plugin flutter_html.
You can add flutter_html and its latest version to the dependencies
section in pubspec.yaml file using the command “flutter pub add
flutter_html.” Then, you have to use “flutter pub get” to execute the
command.
How to do HTML parsing in Flutter
Android developers use the Jsoup library to parse HTML text and code.
But, developers new to the flutter mobile app development do not
know the existence of such a library to parse HTML text and code from
the website in Flutter.
So, are you thinking about the right way to perform HTML parsing in
Flutter for Android or iOS development? Well! Here are the two
different solutions to meet your demands.
Solution: 1
You can now parse the HTML string in this way.
import ‘package:html/parser.dart’;
//here goes the function
String _parseHtmlString(String htmlString) {
var document = parse(htmlString);
String parsedString = parse(document.body.text).documentElement.text;
return parsedString;
}
Solution: 2
Next, you have to fetch data using http.get(url) to the user parser, and
then you can parse whatever you want. Follow the below-mentioned
code properly.
Fetch HTML page:
Future<string> fetchHTML(String url) async {
final response = await http.get(url);
if (response.statusCode == 200)
return response.body;
else throw Exception('Failed');
}</string>
After that, you should call FutureBuilder()
FutureBuilder< String>(
future: fetchHTML('http://your_page.ru/page.html'),
builder: (context, snapshot){
if (snapshot.hasData) {
//Your downloaded page
_temp = snapshot.data;
print(snapshot.data);
return Text('Finished');
}
else if (snapshot.hasError)
return Text('ERROR');
return Text('LOADING');
},
),
Now, you can parse it:
parse(_temp);
Other ways to parse HTML in Flutter
Method: 1
Are you accessing Flutter? Do you wish to parse HTML using
parser.dart? If yes, then run the following code.
<div class="weather-item now">
<span class="time">Now</span>
<div class="temp">19.8<span>℃</span>
<small>(23℃)</small>
</div>
<table>
<tbody><tr>
<th><i class="icon01" aria-label="true"></i></th>
<td>93%</td>
</tr>
<tr>
<th><i class="icon02" aria-label="true"></i></th>
<td>south 2.2km/h</td>
</tr>
<tr>
<th><i class="icon03" aria-label="true"></i></th>
<td>-</td>
</tr>
</tbody></table>
</div>
You may have to use the following command to get this data.
import 'package:html/parser dart’;
output:
19.8,23,93%,south 2.2km/h
Method: 2
Since you access the HTML package, you can obtain the desired data by
accessing some HTML parsing and string processing whenever needed.
Here is the dart sample where you can utilize the parse data function in
your flutter application.
main.dart
import 'package:html/parser.dart' show parse;
main(List<string> args) {
parseData();
}
parseData(){
var document = parse("""
<div class="weather-item now">
<span class="time">Now</span>
<div class="temp">19.8<span>℃</span>
<small>(23℃)</small>
</div>
<table>
<tbody><tr>
<th><i class="icon01" aria-label="true"></i></th>
<td>93%</td>
</tr>
<tr>
<th><i class="icon02" aria-label="true"></i></th>
<td>south 2.2km/h</td>
</tr>
<tr>
<th><i class="icon03" aria-label="true"></i></th>
<td>-</td>
</tr>
</tbody></table>
</div>
""");
//declaring a list of String to hold all the data.
List<string> data = []
data.add(document.getElementsByClassName("time")[0].innerHtml);
//declaring a variable for temp since you use it in multiple places
var temp = document.getElementsByClassName("temp")[0];
data.add(temp.innerHtml.substring(0, temp.innerHtml.indexOf("<span>")));
data.add(temp.getElementsByTagName("small")[0].innerHtml.replaceAll(RegExp("[(|)|℃]"), ""));
//You can also do document.getElementsByTagName("td") but it is more specific here.
var rows = document.getElementsByTagName("table")[0].getElementsByTagName("td");
//Map element to its innerHtml,
because we're gonna need it.
//Iterate over the table-data and then store it safely in the data list
rows.map((e) => e.innerHtml).forEach((element) {
if(element != "-"){
data.add(element);
}
});
//print the data to console.
print(data);
}</span></string></string>
Output
How to parse HTML tags in Flutter
Do you need to parse HTML tags in your flutter project? Well! You can
follow the steps mentioned here to meet your needs instantly.
At first, you should create the flutter application.
Then, you must add the required plugins in pubspec.yaml file as
mentioned below.
dev_dependencies:
flutter_test:
sdk: Flutter
html: ^0.15.0
http: ^0.13.3
flutter_html: ^2.1.0
Now, you have to read the HTML file from the URL. Once you mention
the site, it reads the data online. Use the http:package to read the
data you have accessed and get the http class.
var response=await http.Client().get(Uri.parse(widget.url));
Now, you have HTML data fetched from the URL by accessing the
HTTP package. So, it is the right time to parse the fetched content.
You can use the below code to parse the HTML tags.
var chapters = document.getElementsByClassName("chapters");
chapters.forEach((element) {
var inner = element.innerHtml.toString();
if (inner.contains("href")) {
parse(inner).getElementsByTagName("li").forEach((element) {
var list = element.innerHtml;
if (list.contains("href")) {
//
indexlist_local.add(list.substring(list.indexOf("href=")+6,list.indexOf(">")-1));
indexlist_local.add(IndexContent(title: element.text,
path: list.substring(
list.indexOf("href=") + 6, list.indexOf(">") - 1)));
}
});
}
});
This code is written for fetching the data from the indexed tutorial
page “chapters.” According to the URL you choose, you can change
the index tag.
Finally, you can run the application successfully.
Conclusion
So, you will now be aware of the HTML parsing in Flutter for
android/iOS development. If you do not get the desired result even
after trying all the possible ways, you should seek professional
assistance. Hire Flutter developer to get assistance in HTML parsing and
complete your flutter project without hassle.
Source: https://flutteragency.com/html-parsing-flutter-android-ios-
development/

More Related Content

Similar to HTML Parsing in FLUTTER for Android or iOS Development.pptx

Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53Ivy Rueb
 
IT8005 Electronic Commerces Notes UNIT 1
IT8005 Electronic Commerces Notes UNIT 1IT8005 Electronic Commerces Notes UNIT 1
IT8005 Electronic Commerces Notes UNIT 1ArunsunaiComputer
 
GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009marpierc
 
Arduino LED maXbox starter18_3
Arduino LED maXbox starter18_3Arduino LED maXbox starter18_3
Arduino LED maXbox starter18_3Max Kleiner
 
Maxbox starter18
Maxbox starter18Maxbox starter18
Maxbox starter18Max Kleiner
 
Web Server and how we can design app in C#
Web Server and how we can design app  in C#Web Server and how we can design app  in C#
Web Server and how we can design app in C#caohansnnuedu
 
Metadata Extraction and Content Transformation
Metadata Extraction and Content TransformationMetadata Extraction and Content Transformation
Metadata Extraction and Content TransformationAlfresco Software
 
1 Web Page Foundations Overview This lab walk.docx
1  Web Page Foundations Overview This lab walk.docx1  Web Page Foundations Overview This lab walk.docx
1 Web Page Foundations Overview This lab walk.docxhoney725342
 
Security concerns in microsoft share point 2013
Security concerns in microsoft share point 2013Security concerns in microsoft share point 2013
Security concerns in microsoft share point 2013Ramasubramanian Thumati
 
What is html and how it uses/
What is html and how it uses/What is html and how it uses/
What is html and how it uses/abhishek9260
 
How to Integrate Internet of Things with Webserver with
How to Integrate Internet of Things with Webserver with How to Integrate Internet of Things with Webserver with
How to Integrate Internet of Things with Webserver with Ionela
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 1
Girl Develop It Cincinnati: Intro to HTML/CSS Class 1Girl Develop It Cincinnati: Intro to HTML/CSS Class 1
Girl Develop It Cincinnati: Intro to HTML/CSS Class 1Erin M. Kidwell
 

Similar to HTML Parsing in FLUTTER for Android or iOS Development.pptx (20)

Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
Deck 893ff61f-1fb8-4e15-a379-775dfdbcee77-12-53
 
IT8005 Electronic Commerces Notes UNIT 1
IT8005 Electronic Commerces Notes UNIT 1IT8005 Electronic Commerces Notes UNIT 1
IT8005 Electronic Commerces Notes UNIT 1
 
GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009
 
HTML5
HTML5HTML5
HTML5
 
Php intro
Php introPhp intro
Php intro
 
Ibm
IbmIbm
Ibm
 
Arduino LED maXbox starter18_3
Arduino LED maXbox starter18_3Arduino LED maXbox starter18_3
Arduino LED maXbox starter18_3
 
Html
HtmlHtml
Html
 
HTML Basics by software development company india
HTML Basics by software development company indiaHTML Basics by software development company india
HTML Basics by software development company india
 
Html basics
Html basicsHtml basics
Html basics
 
Maxbox starter18
Maxbox starter18Maxbox starter18
Maxbox starter18
 
Web Server and how we can design app in C#
Web Server and how we can design app  in C#Web Server and how we can design app  in C#
Web Server and how we can design app in C#
 
Metadata Extraction and Content Transformation
Metadata Extraction and Content TransformationMetadata Extraction and Content Transformation
Metadata Extraction and Content Transformation
 
1 Web Page Foundations Overview This lab walk.docx
1  Web Page Foundations Overview This lab walk.docx1  Web Page Foundations Overview This lab walk.docx
1 Web Page Foundations Overview This lab walk.docx
 
Iwt module 1
Iwt  module 1Iwt  module 1
Iwt module 1
 
Day1
Day1Day1
Day1
 
Security concerns in microsoft share point 2013
Security concerns in microsoft share point 2013Security concerns in microsoft share point 2013
Security concerns in microsoft share point 2013
 
What is html and how it uses/
What is html and how it uses/What is html and how it uses/
What is html and how it uses/
 
How to Integrate Internet of Things with Webserver with
How to Integrate Internet of Things with Webserver with How to Integrate Internet of Things with Webserver with
How to Integrate Internet of Things with Webserver with
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 1
Girl Develop It Cincinnati: Intro to HTML/CSS Class 1Girl Develop It Cincinnati: Intro to HTML/CSS Class 1
Girl Develop It Cincinnati: Intro to HTML/CSS Class 1
 

More from Flutter Agency

Use Firebase to Host Your Flutter App on the Web
Use Firebase to Host Your Flutter App on the WebUse Firebase to Host Your Flutter App on the Web
Use Firebase to Host Your Flutter App on the WebFlutter Agency
 
Authentication Made Simple - Exploring QR Auto Login in Flutter.pdf
Authentication Made Simple - Exploring QR Auto Login in Flutter.pdfAuthentication Made Simple - Exploring QR Auto Login in Flutter.pdf
Authentication Made Simple - Exploring QR Auto Login in Flutter.pdfFlutter Agency
 
User Enhancement With Animated Flutter Drawer
User Enhancement With Animated Flutter DrawerUser Enhancement With Animated Flutter Drawer
User Enhancement With Animated Flutter DrawerFlutter Agency
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
Form Validation in Flutter with Laravel Form Validation Syntax
Form Validation in Flutter with Laravel Form Validation SyntaxForm Validation in Flutter with Laravel Form Validation Syntax
Form Validation in Flutter with Laravel Form Validation SyntaxFlutter Agency
 
How to Create Custom Shaders in Flutter?
How to Create Custom Shaders in Flutter?How to Create Custom Shaders in Flutter?
How to Create Custom Shaders in Flutter?Flutter Agency
 
Benefits Of Hiring Flutter App Developers For Success
Benefits Of Hiring Flutter App Developers For SuccessBenefits Of Hiring Flutter App Developers For Success
Benefits Of Hiring Flutter App Developers For SuccessFlutter Agency
 
Guide to Fix Dropdown Button Not Switching Selected Item | Flutter
Guide to Fix Dropdown Button Not Switching Selected Item | FlutterGuide to Fix Dropdown Button Not Switching Selected Item | Flutter
Guide to Fix Dropdown Button Not Switching Selected Item | FlutterFlutter Agency
 
12 Straightforward Steps to Build Your Video On-Demand App in 2024
12 Straightforward Steps to Build Your Video On-Demand App in 202412 Straightforward Steps to Build Your Video On-Demand App in 2024
12 Straightforward Steps to Build Your Video On-Demand App in 2024Flutter Agency
 
Flutter's Advantages For Custom Application Development Services
Flutter's Advantages For Custom Application Development ServicesFlutter's Advantages For Custom Application Development Services
Flutter's Advantages For Custom Application Development ServicesFlutter Agency
 
Hire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
Hire Flutter Developers to Build Cross-Platform App Services - StonesmentorHire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
Hire Flutter Developers to Build Cross-Platform App Services - StonesmentorFlutter Agency
 
A Guide For Recovering Your Failing App Project | Flutter Agency
A Guide For Recovering Your Failing App Project | Flutter AgencyA Guide For Recovering Your Failing App Project | Flutter Agency
A Guide For Recovering Your Failing App Project | Flutter AgencyFlutter Agency
 
Healthcare App-Development Company Fllutter Agency
Healthcare App-Development Company Fllutter AgencyHealthcare App-Development Company Fllutter Agency
Healthcare App-Development Company Fllutter AgencyFlutter Agency
 
Is Flutter Good for Web Development? | Flutter Agency
Is Flutter Good for Web Development? | Flutter AgencyIs Flutter Good for Web Development? | Flutter Agency
Is Flutter Good for Web Development? | Flutter AgencyFlutter Agency
 
Choosing App Development: Native, Hybrid, or Flutter Explained
Choosing App Development: Native, Hybrid, or Flutter ExplainedChoosing App Development: Native, Hybrid, or Flutter Explained
Choosing App Development: Native, Hybrid, or Flutter ExplainedFlutter Agency
 
The Role of Digital Transformation in Healthcare - Flutter Agency.pdf
The Role of Digital Transformation in Healthcare - Flutter Agency.pdfThe Role of Digital Transformation in Healthcare - Flutter Agency.pdf
The Role of Digital Transformation in Healthcare - Flutter Agency.pdfFlutter Agency
 
Why-Hire-Flutter-Developer-Flutter-Agency_.pdf
Why-Hire-Flutter-Developer-Flutter-Agency_.pdfWhy-Hire-Flutter-Developer-Flutter-Agency_.pdf
Why-Hire-Flutter-Developer-Flutter-Agency_.pdfFlutter Agency
 
Streamlining DNS Checks in Flutter Apps
Streamlining DNS Checks in Flutter AppsStreamlining DNS Checks in Flutter Apps
Streamlining DNS Checks in Flutter AppsFlutter Agency
 
Flutter UI/UX Design Tools: The Ultimate Guide for 2023
Flutter UI/UX Design Tools: The Ultimate Guide for 2023Flutter UI/UX Design Tools: The Ultimate Guide for 2023
Flutter UI/UX Design Tools: The Ultimate Guide for 2023Flutter Agency
 
Flutter Developer Skills to Master in 2024.pdf
Flutter Developer Skills to Master in 2024.pdfFlutter Developer Skills to Master in 2024.pdf
Flutter Developer Skills to Master in 2024.pdfFlutter Agency
 

More from Flutter Agency (20)

Use Firebase to Host Your Flutter App on the Web
Use Firebase to Host Your Flutter App on the WebUse Firebase to Host Your Flutter App on the Web
Use Firebase to Host Your Flutter App on the Web
 
Authentication Made Simple - Exploring QR Auto Login in Flutter.pdf
Authentication Made Simple - Exploring QR Auto Login in Flutter.pdfAuthentication Made Simple - Exploring QR Auto Login in Flutter.pdf
Authentication Made Simple - Exploring QR Auto Login in Flutter.pdf
 
User Enhancement With Animated Flutter Drawer
User Enhancement With Animated Flutter DrawerUser Enhancement With Animated Flutter Drawer
User Enhancement With Animated Flutter Drawer
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Form Validation in Flutter with Laravel Form Validation Syntax
Form Validation in Flutter with Laravel Form Validation SyntaxForm Validation in Flutter with Laravel Form Validation Syntax
Form Validation in Flutter with Laravel Form Validation Syntax
 
How to Create Custom Shaders in Flutter?
How to Create Custom Shaders in Flutter?How to Create Custom Shaders in Flutter?
How to Create Custom Shaders in Flutter?
 
Benefits Of Hiring Flutter App Developers For Success
Benefits Of Hiring Flutter App Developers For SuccessBenefits Of Hiring Flutter App Developers For Success
Benefits Of Hiring Flutter App Developers For Success
 
Guide to Fix Dropdown Button Not Switching Selected Item | Flutter
Guide to Fix Dropdown Button Not Switching Selected Item | FlutterGuide to Fix Dropdown Button Not Switching Selected Item | Flutter
Guide to Fix Dropdown Button Not Switching Selected Item | Flutter
 
12 Straightforward Steps to Build Your Video On-Demand App in 2024
12 Straightforward Steps to Build Your Video On-Demand App in 202412 Straightforward Steps to Build Your Video On-Demand App in 2024
12 Straightforward Steps to Build Your Video On-Demand App in 2024
 
Flutter's Advantages For Custom Application Development Services
Flutter's Advantages For Custom Application Development ServicesFlutter's Advantages For Custom Application Development Services
Flutter's Advantages For Custom Application Development Services
 
Hire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
Hire Flutter Developers to Build Cross-Platform App Services - StonesmentorHire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
Hire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
 
A Guide For Recovering Your Failing App Project | Flutter Agency
A Guide For Recovering Your Failing App Project | Flutter AgencyA Guide For Recovering Your Failing App Project | Flutter Agency
A Guide For Recovering Your Failing App Project | Flutter Agency
 
Healthcare App-Development Company Fllutter Agency
Healthcare App-Development Company Fllutter AgencyHealthcare App-Development Company Fllutter Agency
Healthcare App-Development Company Fllutter Agency
 
Is Flutter Good for Web Development? | Flutter Agency
Is Flutter Good for Web Development? | Flutter AgencyIs Flutter Good for Web Development? | Flutter Agency
Is Flutter Good for Web Development? | Flutter Agency
 
Choosing App Development: Native, Hybrid, or Flutter Explained
Choosing App Development: Native, Hybrid, or Flutter ExplainedChoosing App Development: Native, Hybrid, or Flutter Explained
Choosing App Development: Native, Hybrid, or Flutter Explained
 
The Role of Digital Transformation in Healthcare - Flutter Agency.pdf
The Role of Digital Transformation in Healthcare - Flutter Agency.pdfThe Role of Digital Transformation in Healthcare - Flutter Agency.pdf
The Role of Digital Transformation in Healthcare - Flutter Agency.pdf
 
Why-Hire-Flutter-Developer-Flutter-Agency_.pdf
Why-Hire-Flutter-Developer-Flutter-Agency_.pdfWhy-Hire-Flutter-Developer-Flutter-Agency_.pdf
Why-Hire-Flutter-Developer-Flutter-Agency_.pdf
 
Streamlining DNS Checks in Flutter Apps
Streamlining DNS Checks in Flutter AppsStreamlining DNS Checks in Flutter Apps
Streamlining DNS Checks in Flutter Apps
 
Flutter UI/UX Design Tools: The Ultimate Guide for 2023
Flutter UI/UX Design Tools: The Ultimate Guide for 2023Flutter UI/UX Design Tools: The Ultimate Guide for 2023
Flutter UI/UX Design Tools: The Ultimate Guide for 2023
 
Flutter Developer Skills to Master in 2024.pdf
Flutter Developer Skills to Master in 2024.pdfFlutter Developer Skills to Master in 2024.pdf
Flutter Developer Skills to Master in 2024.pdf
 

Recently uploaded

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Recently uploaded (20)

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

HTML Parsing in FLUTTER for Android or iOS Development.pptx

  • 1.
  • 2. HTML Parsing in FLUTTER for Android / iOS Development The HTML parser is the structured markup processing tool defining the HTML Parser class. It is often accessed to parse HTML files. Parsing is to resolve into component parts and then describe their syntactic roles. In general, parsing analyzes the String of the symbols in computer or natural languages. When speaking about HTML parsing, it takes the HTML code and extracts the relevant information, such as the page’s title, headings, paragraphs, links, bold text, and much more. Keep reading this article to learn much about HTML parsing in Flutter for android or iOS platforms! If you need professional assistance, do not hesitate to contact the reputable and trustworthy Flutter app development company.
  • 3. Introduction to flutter HTML Flutter is an open-source, cross-platform mobile app development framework. It is highly compatible with the present web rendering technologies such as HTML, JavaScript, and CSS. Therefore, it is a perfect platform for web and mobile app development. With the help of Flutter developers, you can compile the existing code into the client experience, implant it into the browser and finally deploy it to any web server.
  • 4. When you build the application with Flutter and need to render some HTML content, you can do it easily by accessing the plugin flutter_html. You can add flutter_html and its latest version to the dependencies section in pubspec.yaml file using the command “flutter pub add flutter_html.” Then, you have to use “flutter pub get” to execute the command.
  • 5. How to do HTML parsing in Flutter Android developers use the Jsoup library to parse HTML text and code. But, developers new to the flutter mobile app development do not know the existence of such a library to parse HTML text and code from the website in Flutter. So, are you thinking about the right way to perform HTML parsing in Flutter for Android or iOS development? Well! Here are the two different solutions to meet your demands.
  • 6. Solution: 1 You can now parse the HTML string in this way. import ‘package:html/parser.dart’; //here goes the function String _parseHtmlString(String htmlString) { var document = parse(htmlString); String parsedString = parse(document.body.text).documentElement.text; return parsedString; } Solution: 2 Next, you have to fetch data using http.get(url) to the user parser, and then you can parse whatever you want. Follow the below-mentioned code properly.
  • 7. Fetch HTML page: Future<string> fetchHTML(String url) async { final response = await http.get(url); if (response.statusCode == 200) return response.body; else throw Exception('Failed'); }</string> After that, you should call FutureBuilder()
  • 8. FutureBuilder< String>( future: fetchHTML('http://your_page.ru/page.html'), builder: (context, snapshot){ if (snapshot.hasData) { //Your downloaded page _temp = snapshot.data; print(snapshot.data); return Text('Finished'); } else if (snapshot.hasError) return Text('ERROR'); return Text('LOADING'); }, ),
  • 9. Now, you can parse it: parse(_temp); Other ways to parse HTML in Flutter Method: 1 Are you accessing Flutter? Do you wish to parse HTML using parser.dart? If yes, then run the following code.
  • 10. <div class="weather-item now"> <span class="time">Now</span> <div class="temp">19.8<span>℃</span> <small>(23℃)</small> </div> <table> <tbody><tr> <th><i class="icon01" aria-label="true"></i></th> <td>93%</td> </tr> <tr> <th><i class="icon02" aria-label="true"></i></th> <td>south 2.2km/h</td> </tr> <tr> <th><i class="icon03" aria-label="true"></i></th> <td>-</td> </tr> </tbody></table> </div>
  • 11. You may have to use the following command to get this data. import 'package:html/parser dart’; output: 19.8,23,93%,south 2.2km/h Method: 2 Since you access the HTML package, you can obtain the desired data by accessing some HTML parsing and string processing whenever needed. Here is the dart sample where you can utilize the parse data function in your flutter application.
  • 12. main.dart import 'package:html/parser.dart' show parse; main(List<string> args) { parseData(); } parseData(){ var document = parse(""" <div class="weather-item now"> <span class="time">Now</span> <div class="temp">19.8<span>℃</span> <small>(23℃)</small> </div> <table> <tbody><tr> <th><i class="icon01" aria-label="true"></i></th> <td>93%</td> </tr> <tr>
  • 13. <th><i class="icon02" aria-label="true"></i></th> <td>south 2.2km/h</td> </tr> <tr> <th><i class="icon03" aria-label="true"></i></th> <td>-</td> </tr> </tbody></table> </div> """);
  • 14. //declaring a list of String to hold all the data. List<string> data = [] data.add(document.getElementsByClassName("time")[0].innerHtml); //declaring a variable for temp since you use it in multiple places var temp = document.getElementsByClassName("temp")[0]; data.add(temp.innerHtml.substring(0, temp.innerHtml.indexOf("<span>"))); data.add(temp.getElementsByTagName("small")[0].innerHtml.replaceAll(RegExp("[(|)|℃]"), "")); //You can also do document.getElementsByTagName("td") but it is more specific here. var rows = document.getElementsByTagName("table")[0].getElementsByTagName("td"); //Map element to its innerHtml, because we're gonna need it. //Iterate over the table-data and then store it safely in the data list rows.map((e) => e.innerHtml).forEach((element) { if(element != "-"){ data.add(element); } }); //print the data to console. print(data); }</span></string></string>
  • 15. Output How to parse HTML tags in Flutter Do you need to parse HTML tags in your flutter project? Well! You can follow the steps mentioned here to meet your needs instantly. At first, you should create the flutter application. Then, you must add the required plugins in pubspec.yaml file as mentioned below.
  • 16. dev_dependencies: flutter_test: sdk: Flutter html: ^0.15.0 http: ^0.13.3 flutter_html: ^2.1.0 Now, you have to read the HTML file from the URL. Once you mention the site, it reads the data online. Use the http:package to read the data you have accessed and get the http class. var response=await http.Client().get(Uri.parse(widget.url)); Now, you have HTML data fetched from the URL by accessing the HTTP package. So, it is the right time to parse the fetched content. You can use the below code to parse the HTML tags.
  • 17. var chapters = document.getElementsByClassName("chapters"); chapters.forEach((element) { var inner = element.innerHtml.toString(); if (inner.contains("href")) { parse(inner).getElementsByTagName("li").forEach((element) { var list = element.innerHtml; if (list.contains("href")) { // indexlist_local.add(list.substring(list.indexOf("href=")+6,list.indexOf(">")-1)); indexlist_local.add(IndexContent(title: element.text, path: list.substring( list.indexOf("href=") + 6, list.indexOf(">") - 1))); } }); } }); This code is written for fetching the data from the indexed tutorial page “chapters.” According to the URL you choose, you can change the index tag. Finally, you can run the application successfully.
  • 18. Conclusion So, you will now be aware of the HTML parsing in Flutter for android/iOS development. If you do not get the desired result even after trying all the possible ways, you should seek professional assistance. Hire Flutter developer to get assistance in HTML parsing and complete your flutter project without hassle. Source: https://flutteragency.com/html-parsing-flutter-android-ios- development/