コード例 #1
0
ファイル: encoder.go プロジェクト: magicmonty/wbxml-go
func (e *Encoder) encodeCharData(el xml.CharData) error {
	if e.currentElement != nil {
		if strings.Trim(fmt.Sprintf("%s", el), " \n\r\t") != "" {
			e.currentElement.AddContent(el.Copy())
		}
	}
	return nil
}
コード例 #2
0
ファイル: xml.go プロジェクト: gravitational/configure
// ReplaceCDATAIf replaces CDATA value of the matched node
// if the parent node name matches the name
func ReplaceCDATAIf(val xml.CharData, cond ConditionFunc) TransformFunc {
	return func(parents *NodeList, in xml.Token) []xml.Token {
		switch in.(type) {
		case xml.CharData:
			if cond(parents, in) {
				return []xml.Token{val.Copy()}
			}
		}
		return []xml.Token{in}
	}
}
コード例 #3
0
ファイル: text.go プロジェクト: it-man-cn/godom
func newText(token xml.CharData) *_text {
	n := newNode(TEXT_NODE)
	t := &_text{_cdata{n, token.Copy()}}
	n.self = Node(t)
	return t
}
コード例 #4
0
ファイル: characterdata.go プロジェクト: it-man-cn/godom
func newCData(token xml.CharData) *_cdata {
	n := newNode(CDATA_SECTION_NODE)
	cd := &_cdata{n, token.Copy()}
	n.self = Node(cd)
	return cd
}