Documentation
¶
Index ¶
- Constants
- type CharsetReader
- type Option
- type XMLEventType
- type XMLPullParser
- func (p *XMLPullParser) Attribute(name string) string
- func (p *XMLPullParser) AttributeNS(name, space string) string
- func (p *XMLPullParser) DecodeElement(v any) error
- func (p *XMLPullParser) EventName(e XMLEventType) string
- func (p *XMLPullParser) EventType(t xml.Token) XMLEventType
- func (p *XMLPullParser) Expect(event XMLEventType, name string) (err error)
- func (p *XMLPullParser) ExpectAll(event XMLEventType, space, name string) error
- func (p *XMLPullParser) IsWhitespace() bool
- func (p *XMLPullParser) Next() (event XMLEventType, err error)
- func (p *XMLPullParser) NextTag() (event XMLEventType, err error)
- func (p *XMLPullParser) NextText() (string, error)
- func (p *XMLPullParser) NextToken() (XMLEventType, error)
- func (p *XMLPullParser) Skip() error
- func (p *XMLPullParser) Text() string
- func (p *XMLPullParser) Token() xml.Token
- func (p *XMLPullParser) XmlBaseResolveUrl(u string) (*url.URL, error)
- func (p *XMLPullParser) XmlBaseResolver() func(string) (*url.URL, error)
Constants ¶
const (
XMLnamespace = "http://www.w3.org/XML/1998/namespace"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(p *XMLPullParser)
func WithDecoder ¶
WithDecoder configures XMLPullParser with custom xml.Decoder.
NewXMLPullParser will override xml.Decoder.Strict and xml.Decoder.CharsetReader.
type XMLEventType ¶
type XMLEventType int
const ( StartDocument XMLEventType = iota EndDocument StartTag EndTag Text Comment ProcessingInstruction Directive IgnorableWhitespace // TODO: ? )
type XMLPullParser ¶
type XMLPullParser struct {
// Document State
Spaces map[string]string
SpacesStack []map[string]string
BaseStack urlStack
// Token State
Depth int
Event XMLEventType
Attrs []xml.Attr
Name string
Space string
// contains filtered or unexported fields
}
func NewXMLPullParser ¶
func NewXMLPullParser(r io.Reader, strict bool, cr CharsetReader, opts ...Option, ) *XMLPullParser
func (*XMLPullParser) Attribute ¶
func (p *XMLPullParser) Attribute(name string) string
func (*XMLPullParser) AttributeNS ¶ added in v2.1.0
func (p *XMLPullParser) AttributeNS(name, space string) string
AttributeNS returns value of an attribute named name in namespace space or empty string if not found.
func (*XMLPullParser) DecodeElement ¶
func (p *XMLPullParser) DecodeElement(v any) error
func (*XMLPullParser) EventName ¶
func (p *XMLPullParser) EventName(e XMLEventType) string
func (*XMLPullParser) EventType ¶
func (p *XMLPullParser) EventType(t xml.Token) XMLEventType
func (*XMLPullParser) Expect ¶
func (p *XMLPullParser) Expect(event XMLEventType, name string) (err error)
func (*XMLPullParser) ExpectAll ¶
func (p *XMLPullParser) ExpectAll(event XMLEventType, space, name string) error
func (*XMLPullParser) IsWhitespace ¶
func (p *XMLPullParser) IsWhitespace() bool
func (*XMLPullParser) Next ¶
func (p *XMLPullParser) Next() (event XMLEventType, err error)
func (*XMLPullParser) NextTag ¶
func (p *XMLPullParser) NextTag() (event XMLEventType, err error)
func (*XMLPullParser) NextText ¶
func (p *XMLPullParser) NextText() (string, error)
func (*XMLPullParser) NextToken ¶
func (p *XMLPullParser) NextToken() (XMLEventType, error)
func (*XMLPullParser) Skip ¶
func (p *XMLPullParser) Skip() error
Skip consumes tokens until the end tag matching the element the parser is currently positioned on. It is iterative (a depth counter rather than recursion) so deeply nested input can't overflow the goroutine stack, and it bails on EndDocument instead of looping forever on a truncated stream.
func (*XMLPullParser) Text ¶
func (p *XMLPullParser) Text() string
Text returns text of current xml token as string.
func (*XMLPullParser) Token ¶
func (p *XMLPullParser) Token() xml.Token
Token returns the current XML token in the input stream.
Slices of bytes in the returned token data refer to the parser's internal buffer and remain valid only for the current state. To acquire a copy of the bytes, call xml.CopyToken or the token's Copy method.
func (*XMLPullParser) XmlBaseResolveUrl ¶
func (p *XMLPullParser) XmlBaseResolveUrl(u string) (*url.URL, error)
resolve the given string as a URL relative to current xml:base
func (*XMLPullParser) XmlBaseResolver ¶ added in v2.0.3
func (p *XMLPullParser) XmlBaseResolver() func(string) (*url.URL, error)
XmlBaseResolver returns func, which resolves given string as an URL, relative to current xml:base. Can be used anytime later, event when current tag has changed.
