The tags package contains specific tags.
See: Description
Class Summary | |
---|---|
AppletTag | AppletTag represents an <Applet> tag. |
BaseHrefTag | BaseHrefTag represents an <Base> tag. |
BodyTag | A Body Tag. |
Bullet | A bullet tag. |
BulletList | A bullet list tag. |
CompositeTag | The base class for tags that have an end tag. |
DefinitionList | A definition list tag (dl). |
DefinitionListBullet | A definition list bullet tag (either DD or DT). |
Div | A div tag. |
DoctypeTag | The HTML Document Declaration Tag can identify <!DOCTYPE> tags. |
FormTag | Represents a FORM tag. |
FrameSetTag | Identifies an frame set tag. |
FrameTag | Identifies a frame tag |
HeadingTag | A heading (h1 - h6) tag. |
HeadTag | A head tag. |
Html | A html tag. |
ImageTag | Identifies an image tag. |
InputTag | An input tag in a form. |
JspTag | The JSP/ASP tags like <%...%> can be identified by this class. |
LabelTag | A label tag. |
LinkTag | Identifies a link tag. |
MetaTag | A Meta Tag |
ObjectTag | ObjectTag represents an <Object> tag. |
OptionTag | An option tag within a form. |
ParagraphTag | A paragraph (p) tag. |
ProcessingInstructionTag | The XML processing instructions like <? |
ScriptTag | A script tag. |
SelectTag | A select tag within a form. |
Span | A span tag. |
StyleTag | A StyleTag represents a <style> tag. |
TableColumn | A table column tag. |
TableHeader | A table header tag. |
TableRow | A table row tag. |
TableTag | A table tag. |
TextareaTag | A text area tag within a form. |
TitleTag | A title tag. |
This package has implementations of tags that have functionality beyond the capability of a generic tag. For example, the {@.html } tag has methods to get the {@link org.htmlparser.tags.MetaTag#getMetaContent CONTENT} and {@link org.htmlparser.tags.MetaTag#getMetaTagName NAME} attributes (although this could be done with generic attribute manipulation) and an implementation of {@link org.htmlparser.tags.MetaTag#doSemanticAction doSemanticAction} that alters the lexer's encoding.
The classes in this package have been added in an ad-hoc fashion, with the most useful ones having existed a long time, while some obvious ones are rather new. Please feel free to add your own custom tags, and register them with the {@link org.htmlparser.PrototypicalNodeFactory PrototypicalNodeFactory}, and they will be treated like any other in-built tag. In fact tags do not need to reside in this package.
Creating custom tags is fairly straight forward. Simply copy one of the simpler tags you find in this package and alter it as follows.
If the tag can contain other nodes, i.e. {@.html
If it is a simple tag, i.e. {@.html
}, then it should derive from
{@link org.htmlparser.nodes.TagNode TagNode}. See for example
{@link org.htmlparser.tags.MetaTag}
or {@link org.htmlparser.tags.ImageTag}.
To be registered with {@link org.htmlparser.PrototypicalNodeFactory#registerTag},
and especially if it is a composite tag, the tag needs to implement
getIds
which returns the UPPERCASE list of names for the tag
(usually only one), for example "HTML". If the tag can be smart enough to know
what other tags can't be contained within it, it should also implement
{@link org.htmlparser.nodes.TagNode#getEnders getEnders()} which returns the
list of other tags that should cause this tag to close itself, and
{@link org.htmlparser.nodes.TagNode#getEndTagEnders getEndTagEnders()} which
returns the list of end tags (i.e. {@.html }), other than it's own name, that
should cause this tag to close itself. When these 'ender' lists cause a tag to
end before seeing it's own end tag, a virtual end tag is created and 'inserted'
at the location where the end tag should have been. These end tags can be
distinguished because their {@link org.htmlparser.Node#getStartPosition starting}
and {@link org.htmlparser.Node#getEndPosition ending} locations are the same
(i.e. they take up no character length in the HTML stream).
For example, the {@.html
}, or {@.html