function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to use Apex to validate that an XML file conforms to an XSD schema

Is there a way in Apex to take a given XML file and verify that it is valid according to any XSD schemas that it uses? Will any of the various Apex XML parsing classes (i.e. XMLStreamReader, Dom.Document, Ron Hess' XMLDom, or Abhinav Gupta's Fast XML DOM) provide any sort of "validation" that a given XML string that gets loaded into a DOM representation actually conforms to any of its referenced Schemas? Or are there web services for XML validation that any devs know of that I could do a callout to?




Zach McElrath 


Hi Zach,


Did you ever find a solution to this? Can you please share if you did?




Nope - never found a solution. We ended up writing our own validator - it was simpler and achieved our objective, plus the raw XML Editor that we decided to use already checked for valid XML syntax.