Skip to main content

Ens.Util.HTML.Parser

class Ens.Util.HTML.Parser extends %Library.RegisteredObject

HTML screen-scraping parser
The template syntax is like this:
Example:

when C:\test\MenuFind.tmpl contains this:

<b>[sessionevents.csp]</b></A></td><td>{sesstimeoutcomment}
<b>[zipcode.csp]</b>[Demo of using ][ to process client events on the application server.]<A,HREF={zipcodehref}>
=<b>[xmlclasses.csp]</b>[Demo of displaying class instances as XML.]<A,HREF={xmlclasseshref}>
<a,href=http://www.intersystems.com><img,src={cspiscgifname}>
=[CSP Samples Directory][Display class instances as XML]+<tr><A><b>{pageincspdirectory}</b>+
[CSP Samples Directory][Display class instances as XML]<tr><A><b>{pageincspdirectoryagain}
[Text that cannot be matched]{variablethatdoesnotexist}
~<title>{pagetitle}

then

>Do ##class(Ens.Util.HTML.Parser).testFile("http://localhost:57772/csp/samples/menu.csp","C:\test\MenuFind.tmpl",.tOut)
>zw tOut

will yield something like this:

tOut("cspiscgifname")="created-with-csp.gif"
tOut("pageincspdirectory",1)="xmlimport.csp"
tOut("pageincspdirectory",2)="xmlquery.csp"
tOut("pageincspdirectory",3)="zipcode.csp"
tOut("pageinscpdirectoryagain")="xmlimport.csp"
tOut("pagetitle")="CSP Samples Menu"
tOut("sesstimeoutcomment")="Example of how to use the session timeout event."
tOut("xmlclasseshref")="showsource.csp?PAGE=/csp/samples/xmlclasses.csp"
tOut("zipcodehref")="showsource.csp?PAGE=/csp/samples/zipcode.csp"

Method Inventory

Parameters

parameter DOMAIN = Ensemble;
Use our own domain for localization
parameter inText = 1;
parameter inTextVar = 2;
parameter plain = 0;

Methods

classmethod Parse(pHTMLStream As %GlobalCharacterStream, pTemplate As %String, Output pOutDict) as %Status
Parse the the stream pHTMLStream using the pTemplate string; output the resulting variables in the pOutDict array.
classmethod test(pURL As %String, pTemplate As %String, ByRef pOutDict)
classmethod testFile(pURL As %String, pTemplateFile As %String, ByRef pOutDict) as %Status
classmethod testFiles(pFileName As %String, pTemplateFile As %String, ByRef pOutDict) as %Status

Inherited Members

Inherited Methods

FeedbackOpens in a new tab