我想解组一个看起来像的 RDF 文档:
<?xml version="1.0" encoding="WINDOWS-1252"?>
<rdf:RDF xmlns:owl = "http://www.w3.org/2002/07/owl#"
xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
<!-- other xml element -->
</rdf:RDF>
我正在使用这种类型来解压:
type wsdlDoc struct {
XMLName xml.Name `xml:"rdf:RDF"`
Name string `xml:"grounding:hasAtomicProcessGrounding"`
}
执行此操作的代码片段:
// you should import "github.com/rogpeppe/go-charset/charset"
// and _ "github.com/rogpeppe/go-charset/data"
dec := xml.NewDecoder(file)
dec.CharsetReader = charset.NewReader
var v wsdlDoc
err = dec.Decode(&v)
if err != nil {
panic(err)
}
当我运行代码时,恐慌会打印此错误:
panic: expected element type <rdf:RDF> but have <RDF>
如何处理这种解组的情况?
子衿沉夜
相关分类