Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate XML with VS Code

I was a Mac user with BBEdit & Co. Now I'm on Windows with VS Code. I'm looking for an easy solution to validate XML with VS Code. Is there an extension for this?

Thanks!

like image 316
Haeme Ulrich Avatar asked Sep 13 '17 12:09

Haeme Ulrich


2 Answers

For validation against a schema there is XML extension by Red Hat https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml this no longer requires Java since v0.15.0.

It supports a few ways of associating an *.xml with an *.xsd or *.dtd see the docs at https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md#validation-with-xsd-grammar

Most methods involve modifying the files or creating a catalog file but you can also associate files using settings.json.

XSD
"xml.fileAssociations": [
   {
       "pattern": "foo.xml",
       "systemId": "foo.xsd"
   }
]
DTD
"xml.fileAssociations": [
  {
      "pattern": "foo.xml",
      "systemId": "foo.dtd"
  }
]

File paths support wildcards and VS Code variables ${workspaceFolder}, ${fileDirname}, ${fileBasenameNoExtension}

like image 50
Aquila Sands Avatar answered Sep 19 '22 16:09

Aquila Sands


I just wanted to know if my xml syntax was valid, and I didn't want to have to install and setup Java.

XML Tools from Qub worked great for me, I highly recommend it:
https://marketplace.visualstudio.com/items?itemName=qub.qub-xml-vscode

If you need to validate xml against a schema, some of the other more popular extensions might be better

like image 36
Devin Rhode Avatar answered Sep 17 '22 16:09

Devin Rhode