如何使用批处理文件修改xml文件里面的值
<?xmlversion="1.0"encoding="utf-8"?><Configuration><BaseConfigManagePwd="1/n9Rhrbeyd/...
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<BaseConfig ManagePwd="1/n9Rhrbeyd/9DoWaqoMwg==" ManagePwdKey="RO8NMOCB6WJzeSvGoFIz7Q==" ManagePwdIV="alUBL8uuMbA=" />
<ServiceConfig IP="192.168.1.249" Port="50011" FilePath="G:\EGS_Card\EGS\Card\Trunk\Src\EGS.CardCenter\bin" />
<DataBaseConfig DataSource="192.168.1.249,10067" UID="egs_card_dev" PWD="123.com" DB="EGSCard" />
<TaskScheduleConfig Times="1" TimesType="2" />
<OilTime Times="5" TimesType="2" />
<AccsetTime Times="10:45:00" TimesType="2"/>
<ProcName Name="Card_SettleAccount_Pro"/>
</Configuration>
比如:我想修改 <OilTime Times="5" TimesType="2" /> 这一行为 <OilTime Times="50" TimesType="20" /> 怎么修改 ,谢谢,修改的参数可以配置 展开
<Configuration>
<BaseConfig ManagePwd="1/n9Rhrbeyd/9DoWaqoMwg==" ManagePwdKey="RO8NMOCB6WJzeSvGoFIz7Q==" ManagePwdIV="alUBL8uuMbA=" />
<ServiceConfig IP="192.168.1.249" Port="50011" FilePath="G:\EGS_Card\EGS\Card\Trunk\Src\EGS.CardCenter\bin" />
<DataBaseConfig DataSource="192.168.1.249,10067" UID="egs_card_dev" PWD="123.com" DB="EGSCard" />
<TaskScheduleConfig Times="1" TimesType="2" />
<OilTime Times="5" TimesType="2" />
<AccsetTime Times="10:45:00" TimesType="2"/>
<ProcName Name="Card_SettleAccount_Pro"/>
</Configuration>
比如:我想修改 <OilTime Times="5" TimesType="2" /> 这一行为 <OilTime Times="50" TimesType="20" /> 怎么修改 ,谢谢,修改的参数可以配置 展开
推荐于2016-02-17 · 知道合伙人互联网行家
关注
展开全部
使用批处理文件修改xml文件里面的值代码如下:
@Echo Off&Setlocal Enabledelayedexpansion
For /f "tokens=*" %%i in (2.xml) do (
Set str=
For /f "tokens=1-5* delims== " %%j in ("%%i") do (
If "%%j"=="<TaskScheduleConfig" (Set str= %%j %%k="2" %%m="3" %%o)
)
If defined str (Echo !str!) else (Echo %%i)
If defined str (Echo !str!) else (Echo %%i)>>2_new.xml
)
Pause
展开全部
@Echo Off&Setlocal Enabledelayedexpansion
For /f "tokens=*" %%i in (2.xml) do (
Set str=
For /f "tokens=1-5* delims== " %%j in ("%%i") do (
If "%%j"=="<TaskScheduleConfig" (Set str= %%j %%k="2" %%m="3" %%o)
)
If defined str (Echo !str!) else (Echo %%i)
If defined str (Echo !str!) else (Echo %%i)>>2_new.xml
)
Pause
假设2.xml内容为:
<xml>
<TaskScheduleConfig Times="1" TimesType="2" />
<xml>
For /f "tokens=*" %%i in (2.xml) do (
Set str=
For /f "tokens=1-5* delims== " %%j in ("%%i") do (
If "%%j"=="<TaskScheduleConfig" (Set str= %%j %%k="2" %%m="3" %%o)
)
If defined str (Echo !str!) else (Echo %%i)
If defined str (Echo !str!) else (Echo %%i)>>2_new.xml
)
Pause
假设2.xml内容为:
<xml>
<TaskScheduleConfig Times="1" TimesType="2" />
<xml>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
For /f "tokens=* delims=" %%i in (2.xml) do (
For /f "tokens=1-5 delims== " %%j in ("%%i") do (
Set str=
If "%%j"=="<OilTime" (Set "str= <OilTime Times="50" TimesType="20" />")
If defined str (Echo !str!) else (Echo %%i)
If defined str (Echo !str!>>2_new.xml) else (Echo %%i>>2_new.xml)))
Pause
更多追问追答
追问
你可以把我发的文件自己先跑一边,你上面的我已经早就测试过了,错误的
追答
请查看私信附件
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询