Documentation
¶
Overview ¶
Package xml is an XML1.0 lexer following the specifications at http://www.w3.org/TR/xml/.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeAttrVal ¶
EscapeAttrVal returns the escape attribute value bytes without quotes.
Types ¶
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer is the state for the lexer.
func NewLexer ¶
NewLexer returns a new Lexer for a given io.Reader.
Example ¶
l := NewLexer(bytes.NewBufferString("<span class='user'>John Doe</span>"))
out := ""
for {
tt, data, n := l.Next()
if tt == ErrorToken {
break
}
if tt == StartTagToken {
out += "<"
} else if tt == EndTagToken {
out += "</"
}
out += string(data)
if tt == StartTagToken {
out += " "
} else if tt == EndTagToken {
out += ">"
} else if tt == AttributeToken {
out += "=" + string(l.AttrVal())
}
l.Free(n)
}
fmt.Println(out)
Output: <span class='user'>John Doe</span>
func (*Lexer) AttrVal ¶
AttrVal returns the attribute value when an AttributeToken was returned from Next.
func (*Lexer) Err ¶
Err returns the error encountered during lexing, this is often io.EOF but also other errors can be returned.
type TokenType ¶
type TokenType uint32
TokenType determines the type of token, eg. a number or a semicolon.
Click to show internal directories.
Click to hide internal directories.