Single-pass Read and Validate XML vs referenced XSD in C#
问题 I'm trying to read the data from an XML file, validating it against the XSD it suggests, into a single data structure (such as XmlDocument). I have a solution, but it requires 2 passes through the file, and I'm wondering if there's a single-pass solution. MyBooks.xml: <Books xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='books.xsd' id='999'> <Book>Book A</Book> <Book>Book B</Book> </Books> Books.xsd: <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'