Saturday, December 15, 2012

xmllint : Command line XML parser and formatter


So you were given a XML file that came straight out of a windows system with no indentation and incorrect line endings. The simplest way out is xmllint.



The program does much more than formatting its input. Additional functions include: parsing, verifying, dropping empty nodes and many more.



Installing it on CentOS, Fedora and like, is performed via :



sudo yum -y install libxml2


openSUSE users may use yast or type something like:



zypper install libxml2


... while Debian and Ubuntu users will have to go like:



sudo apt-get install libxml2-utils


after you have it on your system, the easy way to fix the badly formated xml file would be :



xmllint --format badlyFormated.xml > wellFormated.xml

0 comments:

Post a Comment