Documentation ¶
Index ¶
- type Attrs
- type Element
- type EndElement
- type KV
- type Reader
- type StartElement
- func (s *StartElement) Attrs() *Attrs
- func (s *StartElement) HasEnd() bool
- func (s *StartElement) Name() string
- func (s *StartElement) NameBytes() []byte
- func (s *StartElement) NameUnsafe() string
- func (s *StartElement) Reset()
- func (s *StartElement) SetName(name string)
- func (s *StartElement) SetNameBytes(name []byte)
- func (s *StartElement) String() string
- type TextElement
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attrs ¶
type Attrs []KV
Attrs represents the attributes of an XML StartElement.
func NewAttrs ¶
NewAttr creates a new attribyte list.
The attributes are a key-value pair of strings. For example: NewAttrs("k", "v") will create the attr k="v".
If the attrs are odd nothing happens. The value associated with that key will be empty.
func (*Attrs) Get ¶
Get returns the attribute based on name.
If the name doesn't match any of the keys KV will be nil.
func (*Attrs) GetBytes ¶
GetBytes returns the attribute based on name.
If the name doesn't match any of the keys KV will be nil.
func (*Attrs) RangePre ¶
RangePre passes every attr to fn.
If fn returns false the range loop will break.
func (*Attrs) RangeWithIndex ¶
RangeWithIndex passes every attr and the index to fn.
type Element ¶
type Element interface { String() string // contains filtered or unexported methods }
Element represents a XML element.
Element can be: - StartElement. - EndElement. - TextElement.
type EndElement ¶
type EndElement struct {
// contains filtered or unexported fields
}
EndElement represents a XML end element.
func (*EndElement) NameBytes ¶
func (e *EndElement) NameBytes() []byte
NameBytes returns the name of the XML node in bytes.
func (*EndElement) NameUnsafe ¶
func (e *EndElement) NameUnsafe() string
NameUnsafe returns a string holding the name parameter.
This function differs from Name() on using unsafe methods.
func (*EndElement) Reset ¶
func (e *EndElement) Reset()
func (*EndElement) SetName ¶
func (e *EndElement) SetName(name string)
SetName sets the name to the end element.
func (*EndElement) SetNameBytes ¶
func (e *EndElement) SetNameBytes(name []byte)
SetNameBytes sets the name to the end element in bytes.
func (*EndElement) String ¶
func (e *EndElement) String() string
String returns the string representation of EndElement.
type KV ¶
type KV struct {
// contains filtered or unexported fields
}
KV represents an attr which is a key-value pair.
func (*KV) KeyUnsafe ¶
KeyUnsafe returns a string holding the name parameter.
This function differs from Key() on using unsafe methods.
func (*KV) ValueUnsafe ¶
ValueUnsafe returns a string holding the name parameter.
This function differs from Value() on using unsafe methods.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader represents a XML reader.
func (*Reader) AssignNext ¶
AssignNext will assign the next TextElement to ptr.
type StartElement ¶
type StartElement struct {
// contains filtered or unexported fields
}
StartElement represents the start of a XML node.
func NewStart ¶
func NewStart(name string, hasEnd bool, attrs *Attrs) *StartElement
NewStart creats a new StartElement.
func (*StartElement) Attrs ¶
func (s *StartElement) Attrs() *Attrs
Attrs returns the attributes of an element.
func (*StartElement) HasEnd ¶
func (s *StartElement) HasEnd() bool
HasEnd indicates if the StartElement ends as /> Having this true means we do not expect a EndElement.
func (*StartElement) Name ¶
func (s *StartElement) Name() string
Name returns the name of the element.
func (*StartElement) NameBytes ¶
func (s *StartElement) NameBytes() []byte
NameBytes returns the name of the element.
func (*StartElement) NameUnsafe ¶
func (s *StartElement) NameUnsafe() string
NameUnsafe returns a string holding the name parameter.
This function differs from Name() on using unsafe methods.
func (*StartElement) Reset ¶
func (s *StartElement) Reset()
Reset sets the default values to the StartElement.
func (*StartElement) SetName ¶
func (s *StartElement) SetName(name string)
SetName sets a string as StartElement's name.
func (*StartElement) SetNameBytes ¶
func (s *StartElement) SetNameBytes(name []byte)
SetNameBytes sets the name bytes to the StartElement.
func (*StartElement) String ¶
func (s *StartElement) String() string
type TextElement ¶
type TextElement string
TextElement represents a XML text.
func (*TextElement) String ¶
func (t *TextElement) String() string
String returns the string representation of TextElement.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is used to write the XML elements.
func (*Writer) WriteIndent ¶
WriteIndent writes the parsed element indentating the elements.