We are using Nokogiri to validate XML files using a XSD. The problem is that the error messages that Nokogiri generates are not very friendly and very hard to translate:

"Element '{http://www.portalfiscal.inf.br/nfe}infNFe': The attribute 'Id' is required but missing."

Does anyone know of a parser or any other way to capture the info needed from the error to generate a more human friendly error?

Until then, we will be doing a custom parser for them... ouch!

有帮助吗?

解决方案

I created a gem for this that is now open source: https://rubygems.org/gems/xml_errors_parser

It seems to work pretty well so far, but number of errors parsed is very few for now. It is however very easy to add new errors, so we will be adding them as needed.

Code reviews and pull requests are always great :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top