z505 / fast-html-parser Goto Github PK
View Code? Open in Web Editor NEWFast HTML Parser for FPC and Delphi
Fast HTML Parser for FPC and Delphi
Hi,
This code returns and an empty HtmlTagEnd as output instead of an empty string and </div>
for HtmlTagEnd.
procedure doHTML;
const
RawHTML =
'<!DOCTYPE html>' + #13#10 +
'<html>' + #13#10 +
'<head>' + #13#10 +
'<meta http-equiv="content-type" content="text/html;' + #13#10 +
'charset=windows-1252">' + #13#10 +
'<title></title>' + #13#10 +
'</head>' + #13#10 +
'<body>' + #13#10 +
'<div align="center"> <font color="#006600"><b>Strong Data Digital' + #13#10 +
'Template</b></font> <br>' + #13#10 +
'<font color="#000099">XML Base64 Encoded Document [xmlDoc]</font>' + #13#10 +
'</div>' + #13#10 +
'<div id="xmlDoc" style="display: none;">' + #13#10 +
'</div>' + #13#10 +
'</body>' + #13#10 +
'</html>';
var
Parser : THTMLParser;
HtmlTag ,
HtmlTagEnd : string;
begin
Parser := THTMLParser.Create(RawHTML);
Memo1.Lines.Text := Parser.GetElementById('xmlDoc',HtmlTag,HtmlTagEnd);
FreeAndNil(Parser);
end;
Best regards.
add 'const' for str params in all funcs where S is not changed.
function IsTag(TagType: string; Tag: string): boolean;
function IsCloseTag(TagType: string; Tag: string): boolean;
function Substr(sub, s: string): boolean;
function StripTabs(s: string): string;
function ReturnsToSpaces(s: string): string;
function LessenSpaces(s: string): string;
function CleanHtm1(s: string): string;
TOnFoundTag = procedure(NoCaseTag, ActualTag: string) of object;
// procedural:
TOnFoundTagP = procedure(NoCaseTag, ActualTag: string);
// when text found in the HTML
TOnFoundText = procedure(Text: string) of object;
// procedural:
TOnFoundTextP = procedure(Text: string);
->
THtmlParserOnFoundTag
THtmlParserOnFoundText
etc
E.g. "html_" prefix
function IsTag(TagType: string; Tag: string): boolean;
function IsCloseTag(TagType: string; Tag: string): boolean;
->
function html_IsTag(TagType: string; Tag: string): boolean;
function html_IsCloseTag(TagType: string; Tag: string): boolean;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.