xpath

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package xpath evaluates XPath 1.0 expressions on HTML and XML documents.

Index

Constants

This section is empty.

Variables

View Source
var ErrEval = errors.New("XPath expression is not valid")

ErrEval reports an expression that cannot be compiled or evaluated.

View Source
var ErrInvalidDocument = errors.New("no root element")

ErrInvalidDocument reports input with no root element.

Functions

This section is empty.

Types

type Document

type Document struct {
	// contains filtered or unexported fields
}

Document is a parsed HTML or XML document.

func Parse

func Parse(text string, f Format) (*Document, error)

Parse parses text as HTML (lenient, namespaces ignored) or XML. For XML, every namespace declared in the document is available by its prefix, and the first default namespace by the prefix `_`.

func (*Document) Eval

func (d *Document) Eval(expr string) (v value.Value, err error)

Eval evaluates expr: numbers give a Float, booleans a Bool, strings a String and node-sets a Nodeset with their size.

type Format

type Format int

Format selects the parser.

const (
	HTML Format = iota
	XML
)

Document formats.

Jump to

Keyboard shortcuts

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