SlideShare a Scribd company logo
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-53
Ivy Rueb
 
IT8005 Electronic Commerces Notes UNIT 1
IT8005 Electronic Commerces Notes UNIT 1IT8005 Electronic Commerces Notes UNIT 1
IT8005 Electronic Commerces Notes UNIT 1
ArunsunaiComputer
 
GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009marpierc
 
HTML5
HTML5HTML5
HTML5
tanamania
 
Arduino LED maXbox starter18_3
Arduino LED maXbox starter18_3Arduino LED maXbox starter18_3
Arduino LED maXbox starter18_3
Max Kleiner
 
Html
HtmlHtml
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
iFour Institute - Sustainable Learning
 
Html basics
Html basicsHtml basics
Html basics
mcatahir947
 
Maxbox starter18
Maxbox starter18Maxbox starter18
Maxbox starter18
Max 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 Transformation
Alfresco 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.docx
honey725342
 
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
Ramasubramanian 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

Flutter App Architecture with Riverpod: An Introduction
Flutter App Architecture with Riverpod: An IntroductionFlutter App Architecture with Riverpod: An Introduction
Flutter App Architecture with Riverpod: An Introduction
Flutter Agency
 
Key Steps To Follow For Google Play Store Closed Testing
Key Steps To Follow For Google Play Store Closed TestingKey Steps To Follow For Google Play Store Closed Testing
Key Steps To Follow For Google Play Store Closed Testing
Flutter Agency
 
Flutter for Web App Development: Exploring the Possibilities
Flutter for Web App Development: Exploring the PossibilitiesFlutter for Web App Development: Exploring the Possibilities
Flutter for Web App Development: Exploring the Possibilities
Flutter Agency
 
Use Of AI in Custom Application Development | Quick Guide
Use Of AI in Custom Application Development | Quick GuideUse Of AI in Custom Application Development | Quick Guide
Use Of AI in Custom Application Development | Quick Guide
Flutter Agency
 
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
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 Web
Flutter 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.pdf
Flutter Agency
 
User Enhancement With Animated Flutter Drawer
User Enhancement With Animated Flutter DrawerUser Enhancement With Animated Flutter Drawer
User Enhancement With Animated Flutter Drawer
Flutter 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 Scenarios
Flutter 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 Syntax
Flutter 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 Success
Flutter 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 | Flutter
Flutter 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 2024
Flutter 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 Services
Flutter 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 - Stonesmentor
Flutter 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 Agency
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
Flutter 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
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
Flutter Agency
 

More from Flutter Agency (20)

Flutter App Architecture with Riverpod: An Introduction
Flutter App Architecture with Riverpod: An IntroductionFlutter App Architecture with Riverpod: An Introduction
Flutter App Architecture with Riverpod: An Introduction
 
Key Steps To Follow For Google Play Store Closed Testing
Key Steps To Follow For Google Play Store Closed TestingKey Steps To Follow For Google Play Store Closed Testing
Key Steps To Follow For Google Play Store Closed Testing
 
Flutter for Web App Development: Exploring the Possibilities
Flutter for Web App Development: Exploring the PossibilitiesFlutter for Web App Development: Exploring the Possibilities
Flutter for Web App Development: Exploring the Possibilities
 
Use Of AI in Custom Application Development | Quick Guide
Use Of AI in Custom Application Development | Quick GuideUse Of AI in Custom Application Development | Quick Guide
Use Of AI in Custom Application Development | Quick Guide
 
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
 
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
 

Recently uploaded

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 

Recently uploaded (20)

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 

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/