加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 22:52:38 所属栏目:百科 来源:网络整理
导读:这是 How to pretty print XML from the command line?的后续问题. libxml2中是否有任何工具可以让我对齐每个节点的属性?我有一个大的XML文档,其逻辑结构我无法改变,但我想转向 a attr="one" bttr="two" tttr="three" fttr="four"/ 成 a attr = "one" bttr
这是 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"/>'

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读