HtmlDocument
Last updated at 12:24 pm UTC on 14 January 2022
Note: the class HtmlDocument class is not available in Squeak 5.1 but it has been included again in 5.3. It was loaded with the Etoys code.
HtmlEntity subclass: #HtmlDocument
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Etoys-Squeakland-Network-HTML-Parser Entities'
An HtmlDocument object represents an object tree of a HTML document. It is created by the class HtmlParser.
It can not be used directly to construct a HTML document.
An HtmlDocument object has two sub-entities: a HtmlHead object and a HtmlBody object.
Query example
To get all anchors a document contains, create the following method:
allAnchors
| a |
a := Set new.
self allSubentitiesDo: [ :e | e class == HtmlAnchor
ifTrue: [a add: e]].
^a
As mentioned above a direct construction of a HtmlDocument is not possible. Workaround:
h := HtmlDocument emptyDocument.
h addToBody: (HtmlParser parse: '<h1>The main title</h1>').
h formattedText
There is a need for a package to construct HTML documents by code, not just reading them.
Reference to such a package?
Maybe HVHtmlBuilder?
Probably rather ZnHtmlOutputStream from the Zinc package.