问题
How do I validate an xml document against an xsd in Visual Studio 2010?
Thanks.
回答1:
Open you XML file in VS2010; in the Properties tool window (F4) there is a Schemas property. List the XSD you want in there. Once done, the errors/warnings will show up in the Error List tool window.
回答2:
There are a few things you need. First the XML Document must be associated with the Schema:
<XmlDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\Code\Schema.xsd">
</XmlDocument>
Now you need to have that Schema XSD Added into your Project. Now when you open the XML Document you should get intellisence and errors / warnings shown as you would errors in your normal C#/VB/etc/ code.
来源:https://stackoverflow.com/questions/8988593/can-you-validate-xsd-against-xml-in-vs-2010