Documentation ¶
Overview ¶
The format/xml package enables creating or manipulating xml data.
var lib = require('format/xml'); var doc = lib.new(); doc.Instruction('xml', 'version="1.0" encoding="UTF-8"'); var res = doc.Element("Response"); var elm = res.Element("Say"); elm.Set("voice", "woman"); elm.Text("Please leave a message after the tone."); var elm = res.Element("Record"); elm.Set("maxLength", "20"); doc.pipe(context.res.body);
Or load a previously generated xml document, and manipulate its contents.
var lib = require('format/xml'); var doc = lib.load(context.req.body); doc.Instruction('xml', 'version="1.0" encoding="UTF-8"'); var elm = doc.Find("People/Person[@id='sally']"); elm.Element("Firstname").Set("value", "Sally"); elm.Element("Lastname").Set("value", "Morgan"); elm.AddComment("Sally is a great person"); elm.AddAttribute("gender", "femals"); elm.Text("Mrs. Sally Morgan"); doc.pipe(context.res.body)
Index ¶
- func New(orb *orbit.Orbit) interface{}
- type Attribute
- type Comment
- type Directive
- type Document
- func (this *Document) Comment(value string) *Comment
- func (this *Document) Comments() []*Comment
- func (this *Document) Directive(value string) *Directive
- func (this *Document) Directives() []*Directive
- func (this *Document) Element(value string) *Element
- func (this *Document) Elements() []*Element
- func (this *Document) Find(path string) *Element
- func (this *Document) Instruction(key, value string) *Instruction
- func (this *Document) Instructions() []*Instruction
- func (this *Document) Load(r io.Reader) *Document
- func (this *Document) Pipe(w io.Writer)
- func (this *Document) Root() *Element
- func (this *Document) Search(path string) []*Element
- func (this *Document) Text(val ...string) string
- type Element
- func (this *Element) Comment(value string) *Comment
- func (this *Element) Comments() []*Comment
- func (this *Element) Del(key string) *Attribute
- func (this *Element) Delete()
- func (this *Element) Directive(value string) *Directive
- func (this *Element) Directives() []*Directive
- func (this *Element) Element(value string) *Element
- func (this *Element) Elements() []*Element
- func (this *Element) Find(path string) *Element
- func (this *Element) Get(key string) *Attribute
- func (this *Element) Instruction(key, value string) *Instruction
- func (this *Element) Instructions() []*Instruction
- func (this *Element) Parent() *Element
- func (this *Element) Search(path string) []*Element
- func (this *Element) Set(key, val string) *Attribute
- func (this *Element) Tag() string
- func (this *Element) Text(val ...string) string
- type Instruction
- type Module
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
func (*Document) Directives ¶
func (*Document) Instruction ¶
func (this *Document) Instruction(key, value string) *Instruction
func (*Document) Instructions ¶
func (this *Document) Instructions() []*Instruction
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
func (*Element) Directives ¶
func (*Element) Instruction ¶
func (this *Element) Instruction(key, value string) *Instruction
func (*Element) Instructions ¶
func (this *Element) Instructions() []*Instruction
type Instruction ¶
type Instruction struct {
// contains filtered or unexported fields
}
func NewInstruction ¶
func NewInstruction(orb *orbit.Orbit, val *etree.ProcInst) *Instruction
func (*Instruction) Delete ¶
func (this *Instruction) Delete()
func (*Instruction) Key ¶
func (this *Instruction) Key(key ...string) string
func (*Instruction) Parent ¶
func (this *Instruction) Parent() *Element
func (*Instruction) Val ¶
func (this *Instruction) Val(val ...string) string
Click to show internal directories.
Click to hide internal directories.