<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[cppby2016的博客]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/cppby2016</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; cppby2016]]></copyright><item><title><![CDATA[简单的 shell 读写xml]]></title><link>https://blog.youkuaiyun.com/cppby2016/article/details/109161619</link><guid>https://blog.youkuaiyun.com/cppby2016/article/details/109161619</guid><author>cppby2016</author><pubDate>Mon, 19 Oct 2020 15:27:25 +0800</pubDate><description><![CDATA[记得刚进公司的时候被大佬要求用shell写一个 xml 读写工具 要求符合 xxx.xx.xx 的父子节点关系

代码如下分享一下

写入xml


#!/bin/sh

array=""
index=0
i_count=1

function set_xml_value()
{   
    if [[ ! -n $1  || ! -n $2  || ! -n $3 ]]
    then
        echo "[ERROR] 参数错误：[$1] [$2] [$3]"
        ret...]]></description><category></category></item></channel></rss>