I'm on Windows and this code works for me. Requires cygwin.
function FixXML()
"save and run xmllint on our file saving output
let tempfile = tempname()
exec "sav! " . tempfile
let outfile = tempname()
let command = "C:\\cygwin\\bin\\xmllint.exe --format " . tempfile . " > " . outfile . " && C:\\cygwin\\bin\\echo.exe -n %errorlevel%"
let result = system(command)
echo result
if result == "0"
"delete everything
1,$delete
"replace it with the result of xmllint
exec "read ++edit" . outfile
"delete the blank line at the top
1,1delete
redraw!
else
let clean_result = substitute(result, tempfile, "Error", 'g')
echo clean_result
endif
endfunction
I'm on Windows and this code works for me. Requires cygwin.