Documentation ¶
Index ¶
- Constants
- Variables
- type AttributeNode
- type CDataNode
- type Document
- type DocumentFragment
- type ElementNode
- type Node
- type NodeSet
- type TextNode
- type WriteBuffer
- type XmlDocument
- func (document *XmlDocument) AddUnlinkedNode(nodePtr unsafe.Pointer)
- func (document *XmlDocument) BookkeepFragment(fragment *DocumentFragment)
- func (document *XmlDocument) CreateCDataNode(data string) (cdata *CDataNode)
- func (document *XmlDocument) CreateElementNode(tag string) (element *ElementNode)
- func (document *XmlDocument) CreateTextNode(data string) (text *TextNode)
- func (document *XmlDocument) DocPtr() (ptr unsafe.Pointer)
- func (document *XmlDocument) DocRef() (d Document)
- func (document *XmlDocument) DocType() (t int)
- func (document *XmlDocument) DocXPathCtx() (ctx *xpath.XPath)
- func (document *XmlDocument) Free()
- func (document *XmlDocument) InputEncoding() (encoding []byte)
- func (document *XmlDocument) OutputEncoding() (encoding []byte)
- func (document *XmlDocument) ParseFragment(input, url []byte, options int) (fragment *DocumentFragment, err error)
- func (document *XmlDocument) RemoveUnlinkedNode(nodePtr unsafe.Pointer) bool
- func (document *XmlDocument) Root() (element *ElementNode)
- type XmlNode
- func (xmlNode *XmlNode) AddChild(data interface{}) (err error)
- func (xmlNode *XmlNode) AddNextSibling(data interface{}) (err error)
- func (xmlNode *XmlNode) AddPreviousSibling(data interface{}) (err error)
- func (xmlNode *XmlNode) Attr(name string) (val string)
- func (xmlNode *XmlNode) Attribute(name string) (attribute *AttributeNode)
- func (xmlNode *XmlNode) Attributes() (attributes map[string]*AttributeNode)
- func (xmlNode *XmlNode) Coerce(data interface{}) (nodes []Node, err error)
- func (xmlNode *XmlNode) Content() string
- func (xmlNode *XmlNode) CountChildren() int
- func (xmlNode *XmlNode) Duplicate(level int) (dup Node)
- func (xmlNode *XmlNode) FirstChild() Node
- func (xmlNode *XmlNode) InnerHtml() string
- func (xmlNode *XmlNode) InsertAfter(data interface{}) (err error)
- func (xmlNode *XmlNode) InsertBefore(data interface{}) (err error)
- func (xmlNode *XmlNode) InsertBegin(data interface{}) (err error)
- func (xmlNode *XmlNode) InsertEnd(data interface{}) (err error)
- func (xmlNode *XmlNode) IsValid() bool
- func (xmlNode *XmlNode) LastChild() Node
- func (xmlNode *XmlNode) MyDocument() (document Document)
- func (xmlNode *XmlNode) Name() (name string)
- func (xmlNode *XmlNode) NextSibling() Node
- func (xmlNode *XmlNode) NodePtr() (p unsafe.Pointer)
- func (xmlNode *XmlNode) NodeType() (nodeType int)
- func (xmlNode *XmlNode) Parent() Node
- func (xmlNode *XmlNode) ParseFragment(input, url []byte, options int) (fragment *DocumentFragment, err error)
- func (xmlNode *XmlNode) Path() (path string)
- func (xmlNode *XmlNode) PreviousSibling() Node
- func (xmlNode *XmlNode) Remove()
- func (xmlNode *XmlNode) Replace(data interface{}) (err error)
- func (xmlNode *XmlNode) ResetChildren()
- func (xmlNode *XmlNode) ResetNodePtr()
- func (xmlNode *XmlNode) Search(data interface{}) (result []Node, err error)
- func (xmlNode *XmlNode) SearchByDeadline(data interface{}, deadline *time.Time) (result []Node, err error)
- func (xmlNode *XmlNode) SetAttr(name, value string) (val string)
- func (xmlNode *XmlNode) SetChildren(data interface{}) (err error)
- func (xmlNode *XmlNode) SetContent(content interface{}) (err error)
- func (xmlNode *XmlNode) SetInnerHtml(data interface{}) (err error)
- func (xmlNode *XmlNode) SetName(name string)
- func (xmlNode *XmlNode) String() string
- func (xmlNode *XmlNode) ToBuffer(outputBuffer []byte) []byte
- func (xmlNode *XmlNode) ToHtml(encoding, outputBuffer []byte) ([]byte, int)
- func (xmlNode *XmlNode) ToXml(encoding, outputBuffer []byte) ([]byte, int)
- func (xmlNode *XmlNode) Unlink()
- func (xmlNode *XmlNode) Wrap(data string) (err error)
Constants ¶
View Source
const ( XML_PARSE_RECOVER = 1 << 0 //relaxed parsing XML_PARSE_NOERROR = 1 << 5 //suppress error reports XML_PARSE_NOWARNING = 1 << 6 //suppress warning reports XML_PARSE_NONET = 1 << 11 //forbid network access )
xml parse option
View Source
const ( XML_ELEMENT_NODE = 1 XML_ATTRIBUTE_NODE = 2 XML_TEXT_NODE = 3 XML_CDATA_SECTION_NODE = 4 XML_ENTITY_REF_NODE = 5 XML_ENTITY_NODE = 6 XML_PI_NODE = 7 XML_COMMENT_NODE = 8 XML_DOCUMENT_NODE = 9 XML_DOCUMENT_TYPE_NODE = 10 XML_DOCUMENT_FRAG_NODE = 11 XML_NOTATION_NODE = 12 XML_HTML_DOCUMENT_NODE = 13 XML_DTD_NODE = 14 XML_ELEMENT_DECL = 15 XML_ATTRIBUTE_DECL = 16 XML_ENTITY_DECL = 17 XML_NAMESPACE_DECL = 18 XML_XINCLUDE_START = 19 XML_XINCLUDE_END = 20 XML_DOCB_DOCUMENT_NODE = 21 )
xmlNode types
View Source
const ( XML_SAVE_FORMAT = 1 // format save output XML_SAVE_NO_DECL = 2 //drop the xml declaration XML_SAVE_NO_EMPTY = 4 //no empty tags XML_SAVE_NO_XHTML = 8 //disable XHTML1 specific rules XML_SAVE_XHTML = 16 //force XHTML1 specific rules XML_SAVE_AS_XML = 32 //force XML serialization on HTML doc XML_SAVE_AS_HTML = 64 //force HTML serialization on XML doc XML_SAVE_WSNONSIG = 128 //format with non-significant whitespace )
View Source
const DefaultEncoding = "utf-8"
libxml2 use "utf-8" by default, and so do we
Variables ¶
View Source
var ( ERR_UNDEFINED_COERCE_PARAM = errors.New("unexpected parameter type in coerce") ERR_UNDEFINED_SET_CONTENT_PARAM = errors.New("unexpected parameter type in SetContent") ERR_UNDEFINED_SEARCH_PARAM = errors.New("unexpected parameter type in Search") ERR_CANNOT_MAKE_DUCMENT_AS_CHILD = errors.New("cannot add a document node as a child") ERR_CANNOT_COPY_TEXT_NODE_WHEN_ADD_CHILD = errors.New("cannot copy a text node when adding it") )
View Source
var DefaultEncodingBytes = []byte(DefaultEncoding)
default encoding in byte slice
View Source
var DefaultParseOption = XML_PARSE_RECOVER | XML_PARSE_NONET | XML_PARSE_NOERROR | XML_PARSE_NOWARNING
default parsing option: relax parsing
View Source
var ERR_FAILED_TO_PARSE_XML = errors.New("failed to parse xml input")
View Source
var ErrEmptyFragment = errors.New("empty xml fragment")
View Source
var ErrFailParseFragment = errors.New("failed to parse xml fragment")
View Source
var ErrTooLarge = errors.New("Output buffer too large")
run out of memory
Functions ¶
This section is empty.
Types ¶
type AttributeNode ¶
type AttributeNode struct {
*XmlNode
}
func (*AttributeNode) SetValue ¶
func (attrNode *AttributeNode) SetValue(val interface{})
func (*AttributeNode) String ¶
func (attrNode *AttributeNode) String() string
func (*AttributeNode) Value ¶
func (attrNode *AttributeNode) Value() string
type Document ¶
type Document interface { /* Nokogiri APIs */ CreateElementNode(string) *ElementNode CreateCDataNode(string) *CDataNode CreateTextNode(string) *TextNode //CreateCommentNode(string) *CommentNode ParseFragment([]byte, []byte, int) (*DocumentFragment, error) DocPtr() unsafe.Pointer DocType() int DocRef() Document InputEncoding() []byte OutputEncoding() []byte DocXPathCtx() *xpath.XPath AddUnlinkedNode(unsafe.Pointer) RemoveUnlinkedNode(unsafe.Pointer) bool Free() String() string Root() *ElementNode BookkeepFragment(*DocumentFragment) }
type DocumentFragment ¶
func ParseFragment ¶
func ParseFragment(content, inEncoding, url []byte, options int, outEncoding []byte) (fragment *DocumentFragment, err error)
func (*DocumentFragment) Children ¶
func (fragment *DocumentFragment) Children() []Node
func (*DocumentFragment) Remove ¶
func (fragment *DocumentFragment) Remove()
func (*DocumentFragment) String ¶
func (fragment *DocumentFragment) String() string
func (*DocumentFragment) ToBuffer ¶
func (fragment *DocumentFragment) ToBuffer(outputBuffer []byte) []byte
type ElementNode ¶
type ElementNode struct {
*XmlNode
}
type Node ¶
type Node interface { NodePtr() unsafe.Pointer ResetNodePtr() MyDocument() Document IsValid() bool ParseFragment([]byte, []byte, int) (*DocumentFragment, error) // NodeType() int NextSibling() Node PreviousSibling() Node Parent() Node FirstChild() Node LastChild() Node CountChildren() int Attributes() map[string]*AttributeNode // Coerce(interface{}) ([]Node, error) // AddChild(interface{}) error AddPreviousSibling(interface{}) error AddNextSibling(interface{}) error InsertBefore(interface{}) error InsertAfter(interface{}) error InsertBegin(interface{}) error InsertEnd(interface{}) error SetInnerHtml(interface{}) error SetChildren(interface{}) error Replace(interface{}) error Wrap(string) error //Swap(interface{}) os.Error // //// SetContent(interface{}) error // Name() string SetName(string) // Attr(string) string SetAttr(string, string) string Attribute(string) *AttributeNode // Path() string // Duplicate(int) Node Search(interface{}) ([]Node, error) SearchByDeadline(interface{}, *time.Time) ([]Node, error) // Unlink() Remove() ResetChildren() //Free() //// ToXml([]byte, []byte) ([]byte, int) ToHtml([]byte, []byte) ([]byte, int) ToBuffer([]byte) []byte String() string Content() string InnerHtml() string }
type NodeSet ¶
func NewNodeSet ¶
type WriteBuffer ¶
type XmlDocument ¶
type XmlDocument struct { Ptr *C.xmlDoc Me Document Node InEncoding []byte OutEncoding []byte UnlinkedNodes map[*C.xmlNode]bool XPathCtx *xpath.XPath Type int InputLen int // contains filtered or unexported fields }
func CreateEmptyDocument ¶
func CreateEmptyDocument(inEncoding, outEncoding []byte) (doc *XmlDocument)
func NewDocument ¶
func NewDocument(p unsafe.Pointer, contentLen int, inEncoding, outEncoding []byte) (doc *XmlDocument)
create a document
func Parse ¶
func Parse(content, inEncoding, url []byte, options int, outEncoding []byte) (doc *XmlDocument, err error)
func (*XmlDocument) AddUnlinkedNode ¶
func (document *XmlDocument) AddUnlinkedNode(nodePtr unsafe.Pointer)
func (*XmlDocument) BookkeepFragment ¶
func (document *XmlDocument) BookkeepFragment(fragment *DocumentFragment)
func (*XmlDocument) CreateCDataNode ¶
func (document *XmlDocument) CreateCDataNode(data string) (cdata *CDataNode)
func (*XmlDocument) CreateElementNode ¶
func (document *XmlDocument) CreateElementNode(tag string) (element *ElementNode)
func (*XmlDocument) CreateTextNode ¶
func (document *XmlDocument) CreateTextNode(data string) (text *TextNode)
func (*XmlDocument) DocPtr ¶
func (document *XmlDocument) DocPtr() (ptr unsafe.Pointer)
func (*XmlDocument) DocRef ¶
func (document *XmlDocument) DocRef() (d Document)
func (*XmlDocument) DocType ¶
func (document *XmlDocument) DocType() (t int)
func (*XmlDocument) DocXPathCtx ¶
func (document *XmlDocument) DocXPathCtx() (ctx *xpath.XPath)
func (*XmlDocument) Free ¶
func (document *XmlDocument) Free()
func (*XmlDocument) InputEncoding ¶
func (document *XmlDocument) InputEncoding() (encoding []byte)
func (*XmlDocument) OutputEncoding ¶
func (document *XmlDocument) OutputEncoding() (encoding []byte)
func (*XmlDocument) ParseFragment ¶
func (document *XmlDocument) ParseFragment(input, url []byte, options int) (fragment *DocumentFragment, err error)
func (*XmlDocument) RemoveUnlinkedNode ¶
func (document *XmlDocument) RemoveUnlinkedNode(nodePtr unsafe.Pointer) bool
func (*XmlDocument) Root ¶
func (document *XmlDocument) Root() (element *ElementNode)
type XmlNode ¶
func (*XmlNode) AddNextSibling ¶
func (*XmlNode) AddPreviousSibling ¶
func (*XmlNode) Attribute ¶
func (xmlNode *XmlNode) Attribute(name string) (attribute *AttributeNode)
func (*XmlNode) Attributes ¶
func (xmlNode *XmlNode) Attributes() (attributes map[string]*AttributeNode)
func (*XmlNode) CountChildren ¶
func (*XmlNode) FirstChild ¶
func (*XmlNode) InsertAfter ¶
func (*XmlNode) InsertBefore ¶
func (*XmlNode) InsertBegin ¶
func (*XmlNode) MyDocument ¶
func (*XmlNode) NextSibling ¶
func (*XmlNode) ParseFragment ¶
func (xmlNode *XmlNode) ParseFragment(input, url []byte, options int) (fragment *DocumentFragment, err error)
func (*XmlNode) PreviousSibling ¶
func (*XmlNode) ResetChildren ¶
func (xmlNode *XmlNode) ResetChildren()
func (*XmlNode) ResetNodePtr ¶
func (xmlNode *XmlNode) ResetNodePtr()
func (*XmlNode) SearchByDeadline ¶
func (*XmlNode) SetChildren ¶
func (*XmlNode) SetContent ¶
func (*XmlNode) SetInnerHtml ¶
Click to show internal directories.
Click to hide internal directories.