Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

go - With golang, how to print full error path when using libxml2 schema.validate() to validate a xml file?

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...