解析xml时如何保留html标记?
我正在尝试解析以下xml。我的解析xml时如何保留html标记?,xml,go,Xml,Go,我正在尝试解析以下xml。我的 主程序包 输入“fmt” 导入“编码/xml” 类型ResultSlice结构{ MyText[]结果`xml:“结果>结果”` } 类型结果结构{ MyResult字符串`xml:“文本”` } func main(){ s:=` 这有风格然后有些没有风格 这里没有风格 再说一次,没有风格 ` r:=&ResultSlice{} 如果err:=xml.Unmarshal([]字节,r);err==nil{ fmt.Println(右) }否则{ fmt.Prin
主程序包
输入“fmt”
导入“编码/xml”
类型ResultSlice结构{
MyText[]结果`xml:“结果>结果”`
}
类型结果结构{
MyResult字符串`xml:“文本”`
}
func main(){
s:=`
这有风格然后有些没有风格
这里没有风格
再说一次,没有风格
`
r:=&ResultSlice{}
如果err:=xml.Unmarshal([]字节,r);err==nil{
fmt.Println(右)
}否则{
fmt.Println(错误)
}
}
这只会打印出纯文本,html标记中的任何内容都会被忽略<代码>此样式将被忽略。我该如何将其包括在内
谢谢 使用
innerxml
标记:
type ResultSlice struct {
MyText []Result `xml:"results>result"`
}
type Result struct {
Text struct {
HTML string `xml:",innerxml"`
} `xml:"text"`
}
游乐场:
type ResultSlice struct {
MyText []Result `xml:"results>result"`
}
type Result struct {
Text struct {
HTML string `xml:",innerxml"`
} `xml:"text"`
}