Documentation ¶
Overview ¶
Package goDOM provides methodes similar to the Javascript Document interface.
It can be used to extract data from HTML documents. See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Document
Index ¶
- type DOM
- func (d *DOM) Attributes() map[string]string
- func (d *DOM) ChildElementCount() int
- func (d *DOM) Children() []*DOM
- func (d *DOM) ClassList() []string
- func (d *DOM) ClassName() string
- func (d *DOM) FirstElementChild() *DOM
- func (d *DOM) GetElementById(id string) *DOM
- func (d *DOM) GetElementsByClassName(class string) []*DOM
- func (d *DOM) GetElementsByTagName(tag string) []*DOM
- func (d *DOM) HasAttribute(key string) bool
- func (d *DOM) HasAttributes() bool
- func (d *DOM) Id() string
- func (d *DOM) LastElementChild() *DOM
- func (d *DOM) NextElementSibling() *DOM
- func (d *DOM) Parent() *DOM
- func (d *DOM) PreviousElementSibling() *DOM
- func (d *DOM) Render() (string, error)
- func (d *DOM) TagName() string
- func (d *DOM) Text(full bool) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DOM ¶
type DOM struct {
// contains filtered or unexported fields
}
A DOM represents a parsed HTML document. It implements methodes to extract data from the document.
func (*DOM) Attributes ¶
Attributes returns a map of all attribute nodes registered to the specified node
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
func (*DOM) ChildElementCount ¶
ChildElementCount returns the number of child elements of this element.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/childElementCount
func (*DOM) Children ¶
Children returns a slice which contains all of the child elements of the element upon which it was called.
The Children slice includes only element nodes. Other node types like text or comment are ignored.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/children
func (*DOM) ClassList ¶
ClassList returns a slice containing all the classes of the current element.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
func (*DOM) ClassName ¶
ClassName returns a string representing the class or space-separated classes of the current element.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/className
func (*DOM) FirstElementChild ¶
FirstElementChild returns the document's first child Element, or nil if there are no child elements.
FirstElementChild includes only element nodes. Other node types like text or comment are ignored.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Document/firstElementChild
func (*DOM) GetElementById ¶
GetElementById returns a DOM object representing the element whose id property matches the specified string.
Since element IDs are required to be unique if specified, they're a useful way to get access to a specific element quickly.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById
func (*DOM) GetElementsByClassName ¶
GetElementsByClassName returns a slice of elements with the given class name.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName
func (*DOM) GetElementsByTagName ¶
GetElementsByTagName returns a slice of elements with the given tag name.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
func (*DOM) HasAttribute ¶
HasAttribute returns a Boolean value indicating whether the specified element has the specified attribute or not.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
func (*DOM) HasAttributes ¶
HasAttribute returns a boolean value indicating whether the current element has any attributes or not.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributes
func (*DOM) Id ¶
Id returns returns a string representing the id of the current element.
If the id value is not the empty string, it must be unique in a document.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/id
func (*DOM) LastElementChild ¶
LastElementChild returns the document's last child Element, or nil if there are no child elements.
LastElementChild includes only element nodes. Other node types like text or comment are ignored.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Document/lastElementChild
func (*DOM) NextElementSibling ¶
NextElementSibling returns the element immediately following the specified one in its parent's children list, or null if the specified element is the last one in the list.
NextElementSibling includes only element nodes. Other node types like text or comment are ignored.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/nextElementSibling
func (*DOM) Parent ¶
Parent returns the parent of the specified node in the DOM tree.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode
func (*DOM) PreviousElementSibling ¶
PreviousElementSibling returns the element immediately prior the specified one in its parent's children list, or null if the specified element is the first one in the list
PreviousElementSibling includes only element nodes. Other node types like text or comment are ignored.
See Javascript equivalent: https://developer.mozilla.org/en-US/docs/Web/API/Element/previousElementSibling