Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
解析xml时如何保留html标记?_Xml_Go - Fatal编程技术网

解析xml时如何保留html标记?

解析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

我正在尝试解析以下xml。我的

主程序包
输入“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"`
}