Here is the basic code from xsd document to validate an XML schema with golang:
schema, err := xsd.Parse(xsdsrc)
if err != nil {
panic(err)
}
defer schema.Free()
if err := schema.Validate(doc); err != nil{
for _, e := range err.(SchemaValidationErr).Error() {
println(e.Error())
}
}
If the validation failed, is there a way that I can know the full path in xml to the field where it has the error?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…