最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
如何用shell生成簡單格式的xml-創(chuàng)新互聯(lián)

這篇文章主要介紹“如何用shell生成簡單格式的xml”,在日常操作中,相信很多人在如何用shell生成簡單格式的xml問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”如何用shell生成簡單格式的xml”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

創(chuàng)新互聯(lián)建站是一家專注于網(wǎng)站建設(shè)、成都網(wǎng)站制作與策劃設(shè)計,西和網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)建站做網(wǎng)站,專注于網(wǎng)站建設(shè)十年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:西和等地區(qū)。西和做網(wǎng)站價格咨詢:028-86922220

以下是shell代碼:
create_xml.sh


代碼如下:

#! /bin/bash

#author: dengzhaoqun
#date: 201202/14

outfile=out
tabs=0

put(){
 echo '<'${*}'>' >> $outfile
}

put_head(){
 put '?'${1}'?'
}

out_tabs(){
 tmp=0
 tabsstr=""
 while [ $tmp -lt $((tabs)) ]
 do
  tabsstr=${tabsstr}'\t'
  tmp=$((tmp+1))
 done
 echo -e -n $tabsstr >> $outfile
}

tag_start(){
 out_tabs
 put $1
 tabs=$((tabs+1))
}

tag_end(){
 tabs=$((tabs-1))
 out_tabs
 put '/'${1}
}

tag_value(){
 out_tabs
 str=""
 str=${1}' value="'${2}'"/'
 put $str
}


以下是測試代碼:
ts_xml.sh


代碼如下:

#! /bin/bash

#author: dengzhaoqun
#date: 20120215

source './create_xml.sh'
put_head 'xml version='1.0' encoding="GBK"'
tag_start '投遞信息'
tag_start '硬件'
tag_value '網(wǎng)卡' 1
tag_end '硬件'
tag_end '投遞信息'


生成的xml文件如下

代碼如下:


<投遞信息>
 <硬件>
  <網(wǎng)卡 value="1"/>
 


到此,關(guān)于“如何用shell生成簡單格式的xml”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
標(biāo)題名稱:如何用shell生成簡單格式的xml-創(chuàng)新互聯(lián)
網(wǎng)站鏈接:http://fisionsoft.com.cn/article/dhgcjo.html