htmldom

package module
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

README

HTML DOM

A library to work with HTML DOM.

Documentation

Index

Constants

View Source
const (
	AttributeAccept          = "accept"
	AttributeAcceptCharset   = "accept-charset"
	AttributeAccesskey       = "accesskey"
	AttributeAction          = "action"
	AttributeAlign           = "align" // Not supported in HTML 5.
	AttributeAllow           = "allow"
	AttributeAlt             = "alt"
	AttributeAsync           = "async"
	AttributeAutocapitalize  = "autocapitalize"
	AttributeAutocomplete    = "autocomplete"
	AttributeAutofocus       = "autofocus"
	AttributeAutoplay        = "autoplay"
	AttributeBackground      = "background"
	AttributeBgcolor         = "bgcolor" // Not supported in HTML 5.
	AttributeBorder          = "border"  // Not supported in HTML 5.
	AttributeBuffered        = "buffered"
	AttributeCapture         = "capture"
	AttributeChallenge       = "challenge"
	AttributeCharset         = "charset"
	AttributeChecked         = "checked"
	AttributeCite            = "cite"
	AttributeClass           = "class"
	AttributeCode            = "code"
	AttributeCodebase        = "codebase"
	AttributeColor           = "color" // Not supported in HTML 5.
	AttributeCols            = "cols"
	AttributeColspan         = "colspan"
	AttributeContent         = "content"
	AttributeContenteditable = "contenteditable"
	AttributeContextmenu     = "contextmenu"
	AttributeControls        = "controls"
	AttributeCoords          = "coords"
	AttributeCrossorigin     = "crossorigin"
	AttributeCsp             = "csp "
	AttributeData            = "data"
	AttributeDataPrefix      = "data-"
	AttributeDatetime        = "datetime"
	AttributeDecoding        = "decoding"
	AttributeDefault         = "default"
	AttributeDefer           = "defer"
	AttributeDir             = "dir"
	AttributeDirname         = "dirname"
	AttributeDisabled        = "disabled"
	AttributeDownload        = "download"
	AttributeDraggable       = "draggable"
	AttributeDropzone        = "dropzone" // Not mentioned on Mozilla's Website.
	AttributeEnctype         = "enctype"
	AttributeEnterkeyhint    = "enterkeyhint "
	AttributeFor             = "for"
	AttributeForm            = "form"
	AttributeFormaction      = "formaction"
	AttributeFormenctype     = "formenctype"
	AttributeFormmethod      = "formmethod"
	AttributeFormnovalidate  = "formnovalidate"
	AttributeFormtarget      = "formtarget"
	AttributeHeaders         = "headers"
	AttributeHeight          = "height"
	AttributeHidden          = "hidden"
	AttributeHigh            = "high"
	AttributeHref            = "href"
	AttributeHreflang        = "hreflang"
	AttributeHttpEquiv       = "http-equiv"
	AttributeIcon            = "icon" // Not mentioned on Mozilla's Website.
	AttributeId              = "id"
	AttributeImportance      = "importance "
	AttributeIntegrity       = "integrity"
	AttributeIntrinsicsize   = "intrinsicsize "
	AttributeInputmode       = "inputmode"
	AttributeIsmap           = "ismap"
	AttributeItemprop        = "itemprop"
	AttributeKeytype         = "keytype"
	AttributeKind            = "kind"
	AttributeLabel           = "label"
	AttributeLang            = "lang"
	AttributeLanguage        = "language"
	AttributeLoading         = "loading "
	AttributeList            = "list"
	AttributeLoop            = "loop"
	AttributeLow             = "low"
	AttributeManifest        = "manifest"
	AttributeMax             = "max"
	AttributeMaxlength       = "maxlength"
	AttributeMinlength       = "minlength"
	AttributeMedia           = "media"
	AttributeMethod          = "method"
	AttributeMin             = "min"
	AttributeMultiple        = "multiple"
	AttributeMuted           = "muted"
	AttributeName            = "name"
	AttributeNovalidate      = "novalidate"

	// Events.
	AttributeOnabort          = "onabort"
	AttributeOnafterprint     = "onafterprint"
	AttributeOnbeforeprint    = "onbeforeprint"
	AttributeOnbeforeunload   = "onbeforeunload"
	AttributeOnblur           = "onblur"
	AttributeOncanplay        = "oncanplay"
	AttributeOncanplaythrough = "oncanplaythrough"
	AttributeOnchange         = "onchange"
	AttributeOnclick          = "onclick"
	AttributeOncontextmenu    = "oncontextmenu"
	AttributeOncopy           = "oncopy"
	AttributeOncuechange      = "oncuechange"
	AttributeOncut            = "oncut"
	AttributeOndblclick       = "ondblclick"
	AttributeOndrag           = "ondrag"
	AttributeOndragend        = "ondragend"
	AttributeOndragenter      = "ondragenter"
	AttributeOndragleave      = "ondragleave"
	AttributeOndragover       = "ondragover"
	AttributeOndragstart      = "ondragstart"
	AttributeOndrop           = "ondrop"
	AttributeOndurationchange = "ondurationchange"
	AttributeOnemptied        = "onemptied"
	AttributeOnended          = "onended"
	AttributeOnerror          = "onerror"
	AttributeOnfocus          = "onfocus"
	AttributeOnhashchange     = "onhashchange"
	AttributeOninput          = "oninput"
	AttributeOninvalid        = "oninvalid"
	AttributeOnkeydown        = "onkeydown"
	AttributeOnkeypress       = "onkeypress"
	AttributeOnkeyup          = "onkeyup"
	AttributeOnload           = "onload"
	AttributeOnloadeddata     = "onloadeddata"
	AttributeOnloadedmetadata = "onloadedmetadata"
	AttributeOnloadstart      = "onloadstart"
	AttributeOnmousedown      = "onmousedown"
	AttributeOnmousemove      = "onmousemove"
	AttributeOnmouseout       = "onmouseout"
	AttributeOnmouseover      = "onmouseover"
	AttributeOnmouseup        = "onmouseup"
	AttributeOnmousewheel     = "onmousewheel"
	AttributeOnoffline        = "onoffline"
	AttributeOnonline         = "ononline"
	AttributeOnpagehide       = "onpagehide"
	AttributeOnpageshow       = "onpageshow"
	AttributeOnpaste          = "onpaste"
	AttributeOnpause          = "onpause"
	AttributeOnplay           = "onplay"
	AttributeOnplaying        = "onplaying"
	AttributeOnpopstate       = "onpopstate"
	AttributeOnprogress       = "onprogress"
	AttributeOnratechange     = "onratechange"
	AttributeOnreset          = "onreset"
	AttributeOnresize         = "onresize"
	AttributeOnscroll         = "onscroll"
	AttributeOnsearch         = "onsearch"
	AttributeOnseeked         = "onseeked"
	AttributeOnseeking        = "onseeking"
	AttributeOnselect         = "onselect"
	AttributeOnstalled        = "onstalled"
	AttributeOnstorage        = "onstorage"
	AttributeOnsubmit         = "onsubmit"
	AttributeOnsuspend        = "onsuspend"
	AttributeOntimeupdate     = "ontimeupdate"
	AttributeOntoggle         = "ontoggle"
	AttributeOnunload         = "onunload"
	AttributeOnvolumechange   = "onvolumechange"
	AttributeOnwaiting        = "onwaiting"
	AttributeOnwheel          = "onwheel"

	AttributeOpen           = "open"
	AttributeOptimum        = "optimum"
	AttributePattern        = "pattern"
	AttributePing           = "ping"
	AttributePlaceholder    = "placeholder"
	AttributePlaysinline    = "playsinline"
	AttributePoster         = "poster"
	AttributePreload        = "preload"
	AttributeRadiogroup     = "radiogroup" // Not mentioned on Mozilla's Website.
	AttributeReadonly       = "readonly"
	AttributeReferrerpolicy = "referrerpolicy"
	AttributeRel            = "rel"
	AttributeRequired       = "required"
	AttributeReversed       = "reversed"
	AttributeRole           = "role"
	AttributeRows           = "rows"
	AttributeRowspan        = "rowspan"
	AttributeSandbox        = "sandbox"
	AttributeScope          = "scope"
	AttributeScoped         = "scoped"
	AttributeSelected       = "selected"
	AttributeShape          = "shape"
	AttributeSize           = "size"
	AttributeSizes          = "sizes"
	AttributeSlot           = "slot"
	AttributeSpan           = "span"
	AttributeSpellcheck     = "spellcheck"
	AttributeSrc            = "src"
	AttributeSrcdoc         = "srcdoc"
	AttributeSrclang        = "srclang"
	AttributeSrcset         = "srcset"
	AttributeStart          = "start"
	AttributeStep           = "step"
	AttributeStyle          = "style"
	AttributeSummary        = "summary"
	AttributeTabindex       = "tabindex"
	AttributeTarget         = "target"
	AttributeTitle          = "title"
	AttributeTranslate      = "translate"
	AttributeType           = "type"
	AttributeUsemap         = "usemap"
	AttributeValue          = "value"
	AttributeWidth          = "width"
	AttributeWrap           = "wrap"
)

HTML Attributes.

View Source
const (
	ErrUnsupportedNodeType   = "unsupported node type"
	ErrNodeIsNotSet          = "node is not set"
	ErrDomNodeIsNotFound     = "DOM node is not found"
	ErrStartingPointIsNotSet = "starting point node is not set"
)
View Source
const (
	TagA          = "a"
	TagAbbr       = "abbr"
	TagAcronym    = "acronym" // Not supported in HTML5.
	TagAddress    = "address"
	TagApplet     = "applet" // Not supported in HTML5.
	TagArea       = "area"
	TagArticle    = "article"
	TagAside      = "aside"
	TagAudio      = "audio"
	TagB          = "b"
	TagBase       = "base"
	TagBasefont   = "basefont" // Not supported in HTML5.
	TagBdi        = "bdi"
	TagBdo        = "bdo"
	TagBig        = "big" // Not supported in HTML5.
	TagBlockquote = "blockquote"
	TagBody       = "body"
	TagBr         = "br"
	TagButton     = "button"
	TagCanvas     = "canvas"
	TagCaption    = "caption"
	TagCenter     = "center" // Not supported in HTML5.
	TagCite       = "cite"
	TagCode       = "code"
	TagCol        = "col"
	TagColgroup   = "colgroup"
	TagData       = "data"
	TagDatalist   = "datalist"
	TagDd         = "dd"
	TagDel        = "del"
	TagDetails    = "details"
	TagDfn        = "dfn"
	TagDialog     = "dialog"
	TagDir        = "dir" // Not supported in HTML5.
	TagDiv        = "div"
	TagDl         = "dl"
	TagDt         = "dt"
	TagEm         = "em"
	TagEmbed      = "embed"
	TagFieldset   = "fieldset"
	TagFigcaption = "figcaption"
	TagFigure     = "figure"
	TagFont       = "font" // Not supported in HTML5.
	TagFooter     = "footer"
	TagForm       = "form"
	TagFrame      = "frame"    // Not supported in HTML5.
	TagFrameset   = "frameset" // Not supported in HTML5.
	TagH1         = "h1"
	TagH2         = "h2"
	TagH3         = "h3"
	TagH4         = "h4"
	TagH5         = "h5"
	TagH6         = "h6"
	TagHead       = "head"
	TagHeader     = "header"
	TagHr         = "hr"
	TagHtml       = "html"
	TagI          = "i"
	TagIframe     = "iframe"
	TagImg        = "img"
	TagInput      = "input"
	TagIns        = "ins"
	TagKbd        = "kbd"
	TagLabel      = "label"
	TagLegend     = "legend"
	TagLi         = "li"
	TagLink       = "link"
	TagMain       = "main"
	TagMap        = "map"
	TagMark       = "mark"
	TagMeta       = "meta"
	TagMeter      = "meter"
	TagNav        = "nav"
	TagNoframes   = "noframes" // Not supported in HTML5.
	TagNoscript   = "noscript"
	TagObject     = "object"
	TagOl         = "ol"
	TagOptgroup   = "optgroup"
	TagOption     = "option"
	TagOutput     = "output"
	TagP          = "p"
	TagParam      = "param"
	TagPicture    = "picture"
	TagPre        = "pre"
	TagProgress   = "progress"
	TagQ          = "q"
	TagRb         = "rb"
	TagRp         = "rp"
	TagRt         = "rt"
	TagRtc        = "rtc"
	TagRuby       = "ruby"
	TagS          = "s"
	TagSamp       = "samp"
	TagScript     = "script"
	TagSection    = "section"
	TagSelect     = "select"
	TagSmall      = "small"
	TagSource     = "source"
	TagSpan       = "span"
	TagStrike     = "strike" // Not supported in HTML5.
	TagStrong     = "strong"
	TagStyle      = "style"
	TagSub        = "sub"
	TagSummary    = "summary"
	TagSup        = "sup"
	TagSvg        = "svg"
	TagTable      = "table"
	TagTbody      = "tbody"
	TagTd         = "td"
	TagTemplate   = "template"
	TagTextarea   = "textarea"
	TagTfoot      = "tfoot"
	TagTh         = "th"
	TagThead      = "thead"
	TagTime       = "time"
	TagTitle      = "title"
	TagTr         = "tr"
	TagTrack      = "track"
	TagTt         = "tt" // Not supported in HTML5.
	TagU          = "u"
	TagUl         = "ul"
	TagVar        = "var"
	TagVideo      = "video"
	TagWbr        = "wbr"
)

HTML Tags.

Variables

This section is empty.

Functions

func GetChildComment added in v0.4.0

func GetChildComment(startingPoint *html.Node) (childNode *html.Node)

GetChildComment searches for the nearest child comment.

func GetChildElement added in v0.4.0

func GetChildElement(startingPoint *html.Node) (childNode *html.Node)

GetChildElement searches for the nearest child element.

func GetChildNodeByTag

func GetChildNodeByTag(startingPoint *html.Node, tagName string) (childNode *html.Node)

GetChildNodeByTag searches for the nearest child node having the specified tag name.

func GetChildNodeByTagAndClass

func GetChildNodeByTagAndClass(startingPoint *html.Node, tagName string, className string) (childNode *html.Node)

GetChildNodeByTagAndClass searches for the nearest child node having the specified tag name and class.

func GetChildNodeByTagAndId

func GetChildNodeByTagAndId(startingPoint *html.Node, tagName string, idName string) (childNode *html.Node)

GetChildNodeByTagAndId searches for the nearest child node having the specified tag name and id.

func GetChildNodeByType added in v0.4.0

func GetChildNodeByType(startingPoint *html.Node, nodeType html.NodeType) (childNode *html.Node)

GetChildNodeByType searches for the nearest child having the specified node type.

func GetChildNodes added in v0.4.0

func GetChildNodes(startingPoint *html.Node) (childNodes []*html.Node)

GetChildNodes returns all child nodes.

func GetChildValue added in v0.4.0

func GetChildValue(startingPoint *html.Node) (childNode *html.Node)

GetChildValue searches for the nearest child [text] value.

func GetChildValueNE added in v0.4.0

func GetChildValueNE(startingPoint *html.Node) (childNode *html.Node)

GetChildValueNE searches for the nearest child [text] value which is not empty.

func GetCleanValue added in v0.4.0

func GetCleanValue(node *html.Node) (cleanValue string)

func GetInnerHtml added in v0.4.0

func GetInnerHtml(node *html.Node) (innerHtml string, err error)

func GetNodeAttributeValue

func GetNodeAttributeValue(node *html.Node, attributeName string) (attributeValue string, attributeExists bool)

GetNodeAttributeValue gets the value of an attribute specified by its name.

func GetOuterHtml added in v0.4.0

func GetOuterHtml(node *html.Node) (outerHtml string, err error)

func GetSiblingComment added in v0.4.0

func GetSiblingComment(startingPoint *html.Node) (siblingNode *html.Node)

GetSiblingComment searches for the nearest sibling comment.

func GetSiblingElement added in v0.4.0

func GetSiblingElement(startingPoint *html.Node) (siblingNode *html.Node)

GetSiblingElement searches for the nearest sibling element.

func GetSiblingNodeByTag

func GetSiblingNodeByTag(startingPoint *html.Node, tagName string) (siblingNode *html.Node)

GetSiblingNodeByTag searches for the nearest sibling node having the specified tag name.

func GetSiblingNodeByTagAndClass

func GetSiblingNodeByTagAndClass(startingPoint *html.Node, tagName string, className string) (siblingNode *html.Node)

GetSiblingNodeByTagAndClass searches for the nearest sibling node having the specified tag name and class.

func GetSiblingNodeByTagAndId

func GetSiblingNodeByTagAndId(startingPoint *html.Node, tagName string, idName string) (siblingNode *html.Node)

GetSiblingNodeByTagAndId searches for the nearest sibling node having the specified tag name and ID.

func GetSiblingNodeByType added in v0.4.0

func GetSiblingNodeByType(startingPoint *html.Node, nodeType html.NodeType) (siblingNode *html.Node)

GetSiblingNodeByType searches for the nearest sibling having the specified node type.

func GetSiblingValue added in v0.4.0

func GetSiblingValue(startingPoint *html.Node) (siblingNode *html.Node)

GetSiblingValue searches for the nearest sibling [text] value.

func GetSiblingValueNE added in v0.4.0

func GetSiblingValueNE(startingPoint *html.Node) (siblingNode *html.Node)

GetSiblingValueNE searches for the nearest sibling [text] value which is not empty.

func HasNonEmptyValue added in v0.4.0

func HasNonEmptyValue(node *html.Node) bool

func NodeHasAttribute

func NodeHasAttribute(node *html.Node, attributeName string) (attributeExists bool)

NodeHasAttribute checks whether the specified node has an attribute with the specified name.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL