can you validate xsd against xml in vs 2010?

▼魔方 西西 提交于 2020-01-02 04:05:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!