Unit simplehtmlparser

Description

This is a simple html parser

Overview

Classes, Interfaces, Objects and Records

Name Description
Record THTMLProperty  

Functions and Procedures

function pcharStartEqual(p1,p2:pchar;l1,l2: SizeInt):boolean;
procedure parseHTML(const html:string; enterTagEvent: TEnterTagEvent; leaveTagEvent: TLeaveTagEvent; textEvent: TTextEvent; commentEvent: TCommentEvent = nil);
procedure parseML(const html:string; const options: TParsingOptions; enterTagEvent: TEnterTagEvent; leaveTagEvent: TLeaveTagEvent; textEvent: TTextEvent; commentEvent: TCommentEvent = nil; processingInstruction: TTextEvent = nil; docType: TDocTypeEvent = nil );
function existPropertyWithValue(propertyName,propertyValue: string; properties:THTMLProperties):boolean;
function getProperty(propertyName: string; properties:THTMLProperties):string;
function findLinkWithText(const html:string;text: string):string;
function findLinkWithProperty(const html:string;prop,value: string):string;
function findTagPropertyValueWithProperty(const html:string;tag,prop_to_get,prop_must_match,value: string):string;

Types

TParsingOptions = set of (poRespectHTMLCDATAElements, poRespectHTMLProcessingInstructions, poRespectXMLProcessingInstructions);
THTMLProperties=array of THTMLProperty;
TParsingResult = (...);
TEnterTagEvent = function (tagName: pchar; tagNameLen: SizeInt; properties: THTMLProperties):TParsingResult of object;
TLeaveTagEvent = function (tagName: pchar; tagNameLen: SizeInt):TParsingResult of object;
TCommentEvent = function (comment: pchar; commentLen: SizeInt):TParsingResult of object;
TDocTypeEvent = procedure (name: pchar; nameLen: SizeInt; more: pchar; moreLen: SizeInt) of object;
TTextFlags = set of (tfCDATA);
TTextEvent = function (text: pchar; textLen: SizeInt; textFlags: TTextFlags):TParsingResult of object;

Description

Functions and Procedures

function pcharStartEqual(p1,p2:pchar;l1,l2: SizeInt):boolean;
 
procedure parseHTML(const html:string; enterTagEvent: TEnterTagEvent; leaveTagEvent: TLeaveTagEvent; textEvent: TTextEvent; commentEvent: TCommentEvent = nil);

This parses html data Notice: You can pass nil for every callback function and if one of them returns prStop, the parsing is aborted.

Parameters
html
The html data
enterTag
Event to be called when a tag is entered
leaveTag
Event to be called when a tag is leaved
textRead
Event to be called when text between tags is read
procedure parseML(const html:string; const options: TParsingOptions; enterTagEvent: TEnterTagEvent; leaveTagEvent: TLeaveTagEvent; textEvent: TTextEvent; commentEvent: TCommentEvent = nil; processingInstruction: TTextEvent = nil; docType: TDocTypeEvent = nil );

This parses html/xml data Notice: You can pass nil for every callback function and if one of them returns prStop, the parsing is aborted.

Parameters
html
Input
options
Set of options to modify the low-level parsing behaviour. (Set it to [poScriptIsCDATA] for html and [] for xml)
enterTag
Event to be called when a tag is entered
leaveTag
Event to be called when a tag is leaved
textRead
Event to be called when text between tags is read
commentEvent
Event to be called when a comment is read
function existPropertyWithValue(propertyName,propertyValue: string; properties:THTMLProperties):boolean;
 
function getProperty(propertyName: string; properties:THTMLProperties):string;
 
function findLinkWithText(const html:string;text: string):string;
 
function findLinkWithProperty(const html:string;prop,value: string):string;
 
function findTagPropertyValueWithProperty(const html:string;tag,prop_to_get,prop_must_match,value: string):string;
 

Types

TParsingOptions = set of (poRespectHTMLCDATAElements, poRespectHTMLProcessingInstructions, poRespectXMLProcessingInstructions);
 
THTMLProperties=array of THTMLProperty;
 
TParsingResult = (...);
 
Values
  • prContinue
  • prStop
TEnterTagEvent = function (tagName: pchar; tagNameLen: SizeInt; properties: THTMLProperties):TParsingResult of object;
 
TLeaveTagEvent = function (tagName: pchar; tagNameLen: SizeInt):TParsingResult of object;
 
TCommentEvent = function (comment: pchar; commentLen: SizeInt):TParsingResult of object;
 
TDocTypeEvent = procedure (name: pchar; nameLen: SizeInt; more: pchar; moreLen: SizeInt) of object;
 
TTextFlags = set of (tfCDATA);
 
TTextEvent = function (text: pchar; textLen: SizeInt; textFlags: TTextFlags):TParsingResult of object;
 

Author


Generated by PasDoc 0.16.0.