Ens.Util.HTML.Parser
class Ens.Util.HTML.Parser extends %Library.RegisteredObject
HTML screen-scraping parserThe template syntax is like this:
- [] Items in square brackets match literal text (text between tags).
- <> Items in angle brackets match HTML tags with the same name. (To match a closing tag, include the '/')
- {} Items in curly braces match literal text and save it under the subscript named in the braces.
- <,=> To match <> tags that have particular attributes, use a comma and equals sign inside the angle brackets. Note that no quoting is required for the RHS.
- <,={}> You can also extract save values from attribute values.
- = Rewind the HTML input and search subsequent template items from the beginning of the HTML input
- ~ Rewind the HTML input and search subsequent template items from the beginning of the HTML input, but only if the HTML stream has already reached its end. Otherwise do nothing and move on to subsequent template items.
- ++ Items appearing between + signs are matched repeatedly. Upon reaching the end of the HTML input, the input is rewound and subsequent template items are searched for.
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}
>Do ##class(Ens.Util.HTML.Parser).testFile("http://localhost:57772/csp/samples/menu.csp","C:\test\MenuFind.tmpl",.tOut)
>zw tOut
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
Methods
Inherited Members
Inherited Methods
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()