How to pretty print XML from the command line?

xmllint This utility comes with libxml2-utils: echo ‘<root><foo a=”b”>lorem</foo><bar value=”ipsum” /></root>’ | xmllint –format – Perl’s XML::Twig This command comes with XML::Twig perl module, sometimes xml-twig-tools package: echo ‘<root><foo a=”b”>lorem</foo><bar value=”ipsum” /></root>’ | xml_pp xmlstarlet This command comes with xmlstarlet: echo ‘<root><foo a=”b”>lorem</foo><bar value=”ipsum” /></root>’ | xmlstarlet format –indent-tab tidy Check the tidy package: echo … Read more

How do I comment out a block of tags in XML?

You can use that style of comment across multiple lines (which exists also in HTML) <detail> <band height=”20″> <!– Hello, I am a multi-line XML comment <staticText> <reportElement x=”180″ y=”0″ width=”200″ height=”20″/> <text><![CDATA[Hello World!]]></text> </staticText> –> </band> </detail>

What does in XML mean?

CDATA stands for Character Data and it means that the data in between these strings includes data that could be interpreted as XML markup, but should not be. The key differences between CDATA and comments are: As Richard points out, CDATA is still part of the document, while a comment is not. In CDATA you … Read more