0

xmllint fileName - checks if the xml defined is right..

Is there any command to indent xml from terminal?

Erwin Bolwidt
  • 30,799
  • 15
  • 56
  • 79
Diya
  • 127
  • 1
  • 9
  • 2
    http://stackoverflow.com/questions/16090869/how-to-pretty-print-xml-from-the-command-line – sndyuk Dec 16 '14 at 05:34
  • xmllint --format filename "prints" the indented output. Is there any command to indent an xmlfile ?In eclipse CTRL+I indents any given piece of code..Similarly is there any command available? – Diya Dec 16 '14 at 05:40

1 Answers1

4

xmllint does have a --format option:

--format
       Reformat and reindent the output. The XMLLINT_INDENT environment
       variable controls the indentation. The default value is two spaces
       " ").
Thilo
  • 257,207
  • 101
  • 511
  • 656
  • 1
    I just found an answer in wiki of vim .Hope this may be useful. Open vimrc file -> au FileType xml exe ":silent %!xmllint --format --recover - 2>/dev/null" ... ! Insert this in autocmd section. Refer http://vim.wikia.com/wiki/Format_your_xml_document_using_xmllint – Diya Dec 17 '14 at 05:48