XML Validation with XSD in Visual Studio IDE

前端 未结 5 1550
别跟我提以往
别跟我提以往 2020-11-28 02:32

I know I have done this before, but it isn\'t working today, nor can I find anywhere that explains how to do it. It could be my lack of sleep, but I suspect gremlins.

5条回答
  •  春和景丽
    2020-11-28 03:25

    You don't need to manually associate the files in Visual Studio - it will automatically match an XML file to a XSD file if you have them both open, and you have your namespace defined correctly.

    To define the namespace:

    In the XML file's root element:

    
        ...
    
    

    In the XSD file's schema element:

    
        ...
    
    

    A note on using Types in your schema when you have a targetNamespace

    Because you are specifying a targetNamespace in your schema, any references to types defined in the schema will need to be prefixed with a namespace (which is why we added the xmlns:this attribute in the above element).

    
    
        
            
            
        
    
    
    
    

提交回复
热议问题