Hi
Does anyone know what advantages (memory/speed) there are by using a class generated by the XSD tool to explore a deserialized XML file as opposed to XPATH?
Hi
Does anyone know what advantages (memory/speed) there are by using a class generated by the XSD tool to explore a deserialized XML file as opposed to XPATH?
The two are very different; but XmlSerializer
will always deserialize entire objects; with XPath you can pick and choose. I'd use XmlSerializer
personally, though - harder to get wrong.
XPath, however, is a complex beast that depends on the back-end. For example, XmlDocument
(mutable) will behave differently to XPathDocument
(read-only, optimized for query).
I'd say the advantage is that you get a strongly typed class which is more convenient to use, and also the constructor for the class will throw an exception if the XML data in the file is invalid for creating the object, so you get a minimal data validation for free.
If you don't want to write boilerplate code, and you need to check ANY values of your XML on the way through, you can't go wrong with the XSD.exe generated classes.