As far as I can tell, the only way of doing it is to use the Microsoft DOM object, but as far as I'm aware this isn't universally available, if you're browsing with Firefox on Linux for example.
For reasons of security and minimizing network traffic I can't pass the xml to an external tool to validate (much as I wish I could). Is there any way of getting javascript to do this regardless of the browser/platform being used?
Might be a tad late for you but maybe it'll help future searchers: http://syssgx.github.io/xml.js/
For browsers that provide it, you can use ActiveX and MSXML. This blog provides a tutorial on using it to do validation.
For Mozilla there is SchemaValidation developed as part of the XForms extension.
Beyond that, there was an SO user asking about his own validator. His question and information may be a place to start if you end up going that route.
See also the javascript and xsd tags on SO when used together.
However I'd suggest that you may want to look into an alternative - validating server-side, perhaps, or checking business logic by using XSLT to transform your XML and thereby prove that it meets your needs.
Ok, after a fair amount of research, it seems the simple answer to this one is 'no', unless I write my own validator in javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With