【发布时间】:2021-05-28 17:37:15
【问题描述】:
如何使用 xmlstarlet 或任何其他 shell 脚本库/工具等以编程方式在 xml 文件中注释/取消注释标记块。
评论中...
输入文件:
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
输出文件:
<note>
<to>Tove</to>
<!-- <from>Jani</from> -->
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
取消注释...
输入文件:
<note>
<to>Tove</to>
<!-- <from>Jani</from> -->
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
输出文件:
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
【问题讨论】:
-
@nahuel 的回答擅长评论但关于取消评论的问题:还有 ' ' 和 '
' 可以取消注释,但我不想取消所有已注释节点的注释
标签: bash shell xmlstarlet