I want to validate large xml files by using xsd schemas in C#. For a file of 1000 lines of xml code validation takes a long time.
Are there any tips and tricks to validate faster?
Can you post some code examples that work faster with large xml validation?
Edit 1 : I validate like this Validating XML with XSD
Edit 2: For large files takes more than 10 seconds. And I need the validation to be very fast under a second.
Edit 3: File size is greater than 10 Mb
Edit 4: I am considering this approach too, I want to store xml file in database and xsd too.
You are currently loading the entire document into memory, which is expensive regardless of validation. A better option is to just parse via a reader, i.e. as shown here on MSDN. The key points from the example on that page:
while(reader.Reader()) just enumerates the entire file at the node levelXmlReaderSettingsIf 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