Documentation
¶
Overview ¶
Package parser provides HTML parsing with rich node traversal. It wraps golang.org/x/net/html nodes into Adaptable structs with parent, children, sibling navigation, text extraction, and attribute access.
Index ¶
- type Adaptable
- func (a *Adaptable) AllChildren() []*Adaptable
- func (a *Adaptable) AllElements() []*Adaptable
- func (a *Adaptable) AllText() string
- func (a *Adaptable) Ancestors() []*Adaptable
- func (a *Adaptable) Attr(name string) string
- func (a *Adaptable) AttrKeys() []string
- func (a *Adaptable) AttrValues() []string
- func (a *Adaptable) Attrs() map[string]string
- func (a *Adaptable) ChildTags() []string
- func (a *Adaptable) Children() []*Adaptable
- func (a *Adaptable) Depth() int
- func (a *Adaptable) Find(tag string) *Adaptable
- func (a *Adaptable) FindAll(tag string) []*Adaptable
- func (a *Adaptable) FindByAttr(key, value string) []*Adaptable
- func (a *Adaptable) FindByText(text string) []*Adaptable
- func (a *Adaptable) HTML() string
- func (a *Adaptable) HasAttr(name string) bool
- func (a *Adaptable) InnerHTML() string
- func (a *Adaptable) NextSibling() *Adaptable
- func (a *Adaptable) Node() *html.Node
- func (a *Adaptable) Parent() *Adaptable
- func (a *Adaptable) Path() []string
- func (a *Adaptable) PathString() string
- func (a *Adaptable) PrevSibling() *Adaptable
- func (a *Adaptable) SiblingTags() []string
- func (a *Adaptable) Siblings() []*Adaptable
- func (a *Adaptable) Tag() string
- func (a *Adaptable) Text() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adaptable ¶
type Adaptable struct {
// contains filtered or unexported fields
}
Adaptable wraps an html.Node with rich traversal and extraction methods.
func NewAdaptable ¶
NewAdaptable wraps an html.Node into an Adaptable.
func ParseFragment ¶
ParseFragment parses an HTML fragment within a body context.
func ParseReader ¶
ParseReader parses HTML from a reader and returns the root Adaptable node.
func (*Adaptable) AllChildren ¶
AllChildren returns all direct child nodes including text nodes.
func (*Adaptable) AllElements ¶
AllElements returns all descendant elements in document order.
func (*Adaptable) AllText ¶
AllText returns all text content recursively from this element and descendants.
func (*Adaptable) Attr ¶
Attr returns the value of the named attribute, or empty string if not found.
func (*Adaptable) AttrValues ¶
AttrValues returns all attribute values.
func (*Adaptable) Children ¶
Children returns all direct child elements (skipping text/comment nodes).
func (*Adaptable) FindByAttr ¶
FindByAttr finds all descendant elements with the given attribute key=value.
func (*Adaptable) FindByText ¶
FindByText finds all descendant elements containing the given text.
func (*Adaptable) NextSibling ¶
NextSibling returns the next sibling element, or nil.
func (*Adaptable) Path ¶
Path returns the DOM path as a slice of tag names from root to this element.
func (*Adaptable) PathString ¶
PathString returns the DOM path as a slash-separated string.
func (*Adaptable) PrevSibling ¶
PrevSibling returns the previous sibling element, or nil.
func (*Adaptable) SiblingTags ¶
SiblingTags returns the tag names of all sibling elements.