mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 17:27:08 +08:00
1 parent
e5685e5c7b
commit
261971cc41
9 files changed
+1072
-4
No files matched your search
@@ -252,6 +252,15 @@ func editorXMLTextValue(data []byte, node *editorXML, before, after string) ([]b
|
||||
content.Reset()
|
||||
content.Write(escaped)
|
||||
}
|
||||
return editorXMLDirectText(data, node, content.Bytes())
|
||||
}
|
||||
|
||||
// editorXMLDirectText 替换直接文本,保留子节点、注释和处理指令
|
||||
// 入参: data 原XML, node 目标节点, text 已转义的文本
|
||||
// 返回: []byte 节点片段, error XML解析错误
|
||||
func editorXMLDirectText(data []byte, node *editorXML, text []byte) ([]byte, error) {
|
||||
var content bytes.Buffer
|
||||
content.Write(text)
|
||||
if node.open < node.close {
|
||||
inner := data[node.open:node.close]
|
||||
decoder := xml.NewDecoder(bytes.NewReader(inner))
|
||||
|
||||
Reference in new issue
Block a user