func (xmlNode *XmlNode) serialize(format SerializationOption, encoding, outputBuffer []byte) ([]byte, int) { nodePtr := unsafe.Pointer(xmlNode.Ptr) var encodingPtr unsafe.Pointer if len(encoding) == 0 { encoding = xmlNode.Document.OutputEncoding() } if len(encoding) > 0 { encodingPtr = unsafe.Pointer(&(encoding[0])) } else { encodingPtr = nil } wbufferMutex.Lock() defer wbufferMutex.Unlock() if outputBuffer == nil { outputBuffer = make([]byte, 0) } wbuffer = &WriteBuffer{Node: xmlNode, Buffer: outputBuffer} ret := int(C.xmlSaveNode(nodePtr, encodingPtr, C.int(format))) if ret < 0 { panic("output error in xml node serialization: " + strconv.Itoa(ret)) } b, o := wbuffer.Buffer, wbuffer.Offset wbuffer = nil return b, o }
func (xmlNode *XmlNode) serialize(format SerializationOption, encoding, outputBuffer []byte) ([]byte, int) { nodePtr := unsafe.Pointer(xmlNode.Ptr) var encodingPtr unsafe.Pointer if len(encoding) == 0 { encoding = xmlNode.Document.OutputEncoding() } if len(encoding) > 0 { encodingPtr = unsafe.Pointer(&(encoding[0])) } else { encodingPtr = nil } wbuffer := &WriteBuffer{Node: xmlNode, Buffer: outputBuffer} wbufferPtr := unsafe.Pointer(wbuffer) ret := int(C.xmlSaveNode(wbufferPtr, nodePtr, encodingPtr, C.int(format))) if ret < 0 { panic("output error in xml node serialization: " + strconv.Itoa(ret)) return nil, 0 } return wbuffer.Buffer, wbuffer.Offset }
func (xmlNode *XmlNode) serialize(format int, encoding, outputBuffer []byte) ([]byte, int) { nodePtr := unsafe.Pointer(xmlNode.Ptr) var encodingPtr unsafe.Pointer if len(encoding) == 0 { encoding = xmlNode.Document.OutputEncoding() } if len(encoding) > 0 { encodingPtr = unsafe.Pointer(&(encoding[0])) } else { encodingPtr = nil } wbuffer := &WriteBuffer{Node: xmlNode, Buffer: outputBuffer} wbufferPtr := unsafe.Pointer(wbuffer) format |= XML_SAVE_FORMAT ret := int(C.xmlSaveNode(wbufferPtr, nodePtr, encodingPtr, C.int(format))) if ret < 0 { fmt.Println("output error!!!") return nil, 0 } return wbuffer.Buffer, wbuffer.Offset }