漂亮的XML(具有属性对齐)

前端之家收集整理的这篇文章主要介绍了漂亮的XML(具有属性对齐)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是 How to pretty print XML from the command line?的后续问题.

libxml2中是否有任何工具可以让我对齐每个节点的属性?我有一个大的XML文档,其逻辑结构我无法改变,但我想转向

<a attr="one" bttr="two" tttr="three" fttr="four"/>

<a attr   = "one"
   bttr   = "two"
   tttr   = "three"
   fttr   = "four"
   longer = "attribute" />

解决方法

xmllint有一个选项–pretty,它支持三个级别的漂亮度.如果这个输出

<?xml version="1.0"?>
<a
    attr="one"
    bttr="two"
    tttr="three"
    fttr="four"
/>

对你好,然后使用–pretty 2:

xmllint --pretty 2 - <<< '<a attr="one" bttr="two" tttr="three" fttr="four"/>'

猜你在找的XML相关文章