-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No error or panic when parsing non-XML #86
Comments
Add |
@zhengchun this is more of a question why |
Sorry. In parse processing, we using https://pkg.go.dev/encoding/xml#NewDecoder to parsing, no extract additional method to check the input document whether is XML or JSON. |
Thanks for reopening! Yes, I was just looking for some way to validate that we have at least well-formed XML before proceeding to parsing (similar to what is recommended by the authors of the gjson package https://github.com/tidwall/gjson#validate-json). My workaround for this right now is to precede the func isXml(someString string) bool {
return xml.Unmarshal([]byte(someString), new(interface{})) == nil
} (the above was inspired by this Stackoverflow answer, which I will say is quite unintuitive) |
I was expecting
Parse
orQuery
to error out if I were to pass in something completely invalid, but it falls all the way through instead:using:
The text was updated successfully, but these errors were encountered: