xml

package
v0.0.0-...-c5bcced Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(orb *orbit.Orbit) interface{}

Types

type Attribute

type Attribute struct {
	// contains filtered or unexported fields
}

func NewAttribute

func NewAttribute(orb *orbit.Orbit, atr *etree.Attr) *Attribute

func (*Attribute) Key

func (this *Attribute) Key(key ...string) string

func (*Attribute) Val

func (this *Attribute) Val(val ...string) string

type Comment

type Comment struct {
	// contains filtered or unexported fields
}

func NewComment

func NewComment(orb *orbit.Orbit, val *etree.Comment) *Comment

func (*Comment) Delete

func (this *Comment) Delete()

func (*Comment) Parent

func (this *Comment) Parent() *Element

func (*Comment) Val

func (this *Comment) Val(val ...string) string

type Directive

type Directive struct {
	// contains filtered or unexported fields
}

func NewDirective

func NewDirective(orb *orbit.Orbit, val *etree.Directive) *Directive

func (*Directive) Delete

func (this *Directive) Delete()

func (*Directive) Parent

func (this *Directive) Parent() *Element

func (*Directive) Val

func (this *Directive) Val(val ...string) string

type Document

type Document struct {
	// contains filtered or unexported fields
}

func NewDocument

func NewDocument(orb *orbit.Orbit, val *etree.Document) *Document

func (*Document) Comment

func (this *Document) Comment(value string) *Comment

func (*Document) Comments

func (this *Document) Comments() []*Comment

func (*Document) Directive

func (this *Document) Directive(value string) *Directive

func (*Document) Directives

func (this *Document) Directives() []*Directive

func (*Document) Element

func (this *Document) Element(value string) *Element

func (*Document) Elements

func (this *Document) Elements() []*Element

func (*Document) Find

func (this *Document) Find(path string) *Element

func (*Document) Instruction

func (this *Document) Instruction(key, value string) *Instruction

func (*Document) Instructions

func (this *Document) Instructions() []*Instruction

func (*Document) Load

func (this *Document) Load(r io.Reader) *Document

func (*Document) Pipe

func (this *Document) Pipe(w io.Writer)

func (*Document) Root

func (this *Document) Root() *Element

func (*Document) Search

func (this *Document) Search(path string) []*Element

func (*Document) Text

func (this *Document) Text(val ...string) string

type Element

type Element struct {
	// contains filtered or unexported fields
}

func NewElement

func NewElement(orb *orbit.Orbit, val *etree.Element) *Element

func (*Element) Comment

func (this *Element) Comment(value string) *Comment

func (*Element) Comments

func (this *Element) Comments() []*Comment

func (*Element) Del

func (this *Element) Del(key string) *Attribute

func (*Element) Delete

func (this *Element) Delete()

func (*Element) Directive

func (this *Element) Directive(value string) *Directive

func (*Element) Directives

func (this *Element) Directives() []*Directive

func (*Element) Element

func (this *Element) Element(value string) *Element

func (*Element) Elements

func (this *Element) Elements() []*Element

func (*Element) Find

func (this *Element) Find(path string) *Element

func (*Element) Get

func (this *Element) Get(key string) *Attribute

func (*Element) Instruction

func (this *Element) Instruction(key, value string) *Instruction

func (*Element) Instructions

func (this *Element) Instructions() []*Instruction

func (*Element) Parent

func (this *Element) Parent() *Element

func (*Element) Search

func (this *Element) Search(path string) []*Element

func (*Element) Set

func (this *Element) Set(key, val string) *Attribute

func (*Element) Tag

func (this *Element) Tag() string

func (*Element) Text

func (this *Element) Text(val ...string) string

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

type Module

type Module struct {
	// contains filtered or unexported fields
}

func (*Module) Load

func (this *Module) Load(i interface{}) *Document

func (*Module) New

func (this *Module) New() *Document

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL