Example #1
0
func xml_Text_Text(ctx *EngineContext, scope *Scope, ins protoface.Instruction, args []interface{}) (returnValue interface{}) {
	input := scope.Value.(string)
	doc, err := xml.Parse([]byte(input), nil, nil, xml.DefaultParseOption, nil)
	if err != nil {
		LogEngineError(ctx, "xml err: "+err.Error())
		returnValue = "false"
		return
	}

	if doc == nil {
		LogEngineError(ctx, "xml err: nil doc")
		returnValue = "false"
		return
	}
	ctx.AddMemoryObject(doc)
	ctx.CurrentDoc = doc
	ns := &Scope{Value: doc}

	for i := 0; i < ins.INumChildren(); i++ {
		child := ins.IGetNthChild(i)
		ctx.RunInstruction(ns, child)
	}

	scope.Value = doc.String()
	ctx.CurrentDoc = nil
	returnValue = scope.Value
	//doc.Free()
	return
}
Example #2
0
func ParseXml(content []byte) (doc *xml.XmlDocument, err error) {
	return xml.Parse(content, xml.DefaultEncodingBytes, nil, xml.DefaultParseOption, xml.DefaultEncodingBytes)
}