Documentation ¶
Index ¶
- Constants
- Variables
- func CalcLocation(buf string, byteoffset int) (line, pos int)
- func NewError(ec ErrCode, buf string, offset int) error
- func ParseTokens(buf string, ontoken func(t *Token) error) error
- type AttributeList
- type Content
- func (ci *Content) ChildStringContent() RawString
- func (ci *Content) Err() error
- func (ci *Content) HandleTag(callback func(attrs AttributeList, content *Content) error)
- func (ci *Content) IsCData() bool
- func (ci *Content) IsComment() bool
- func (ci *Content) IsPI() bool
- func (ci *Content) IsSData() bool
- func (ci *Content) IsTag() bool
- func (ci *Content) IsXmlDecl() bool
- func (ci *Content) Kind() TokenKind
- func (ci *Content) MakeError(prefix, msg string) error
- func (ci *Content) Name() NameString
- func (ci *Content) Next() (ok bool)
- func (ci *Content) NextTag() bool
- func (ci *Content) Raw() (whitePrefix, tokenStr string)
- func (ci *Content) Value() RawString
- type ContentHandler
- type ErrCode
- type Marshaler
- type NameString
- type RawString
- type TagHandler
- type Token
- type TokenKind
- type UnsupportedTypeError
- type Writer
- func (w *Writer) Attr(name string, value interface{})
- func (w *Writer) BOM()
- func (w *Writer) BeginContent()
- func (w *Writer) CTag()
- func (w *Writer) Comment(s string)
- func (w *Writer) OTag(name string)
- func (w *Writer) OptAttr(name string, value interface{})
- func (w *Writer) OptStringAttr(name string, value string)
- func (w *Writer) String(s string)
- func (w *Writer) StringAttr(name string, value string)
- func (w *Writer) Write(v interface{})
- func (w *Writer) XmlDecl()
Constants ¶
View Source
const ( ErrCodeOk = ErrCode(iota) ErrCustom ErrCodeUnexpectedEOF ErrCodeUnexpectedContent ErrCodeUnterminatedQStr ErrCodeUnterminatedCDATA ErrCodeUnsupportedFeature ErrCodeExpectedAttrName ErrCodeExpectedEQ ErrCodeExpectedQStr ErrCodeExpectedOTag ErrCodeInvalidSchema ErrCodeInvalidXmlDecl ErrMismatchingTag ErrCodeMissingRoot ErrUnterminatedComment ErrInvalidComment ErrUnterminatedPI )
View Source
const ( EOF // end of file (buffer) Err // error XmlDecl // <?xml version="1.0" encoding="UTF-8"?> DocTypeDecl // <!DOCTYPE ... > Tag // <identifier CloseEmptyTag // /> BeginContent // > EndContent // </identifier> Attrib // identifier="qstring" or identifier='qstring' SData // content string data CData // cdata tag content Comment // <!-- comment --> PI // <?name value?> )
Variables ¶
View Source
var ErrNoMoreContent = errors.New("no more content available")
Functions ¶
func CalcLocation ¶
Types ¶
type AttributeList ¶
type AttributeList []*Token
type Content ¶
type Content struct {
// contains filtered or unexported fields
}
func (*Content) ChildStringContent ¶
ChildStringContent extracts subnode string content
If subnode is empty, or its content is not a simple string, this function returns empty string.
This is useful for parsing <tag>string-content</tag> nodes
func (*Content) HandleTag ¶
func (ci *Content) HandleTag(callback func(attrs AttributeList, content *Content) error)
func (*Content) Name ¶
func (ci *Content) Name() NameString
type ContentHandler ¶
type NameString ¶
type NameString string
type TagHandler ¶
type TagHandler func(tag *Token, attrs AttributeList, content *Content) error
type Token ¶
type UnsupportedTypeError ¶
UnsupportedTypeError is returned when Marshal encounters a type that cannot be converted into XML.
func (*UnsupportedTypeError) Error ¶
func (e *UnsupportedTypeError) Error() string
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
func (*Writer) BeginContent ¶
func (w *Writer) BeginContent()
func (*Writer) OptStringAttr ¶
func (*Writer) StringAttr ¶
Click to show internal directories.
Click to hide internal directories.