XML Validation with XSD in Visual Studio IDE

前端 未结 5 1555
别跟我提以往
别跟我提以往 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:09

    You'll need to associate the XML document in Visual Studio with the XSD file you have.

    1. You should see something like this in your Properties window of the XML document:

    2. In the XML schema set editor (opens when you click on the (...) ellipsis in the "Schemas" textbox in your Properties window) you need to make sure you have your schema present. Also, make sure the Use column for that schema is enabled - if not, click on it - you'll get a drop-down list of options, pick the Use one with the green checkmark:

    3. Make sure Visual Studio's Error List windows is visible (menu View > Error List). This will show all inconsistencies between XML and XSD schema definitions.

    4. Once all of that is in place, the Visual Studio XML editor should highlight problems with your XML in the editor using blue squigglies:

提交回复
热议问题