中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-12 12:53
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 【新手求助】查找并替换文件中字符串 查看 1,058 回复 4
楼 主 【新手求助】查找并替换文件中字符串 发表于 2010-03-16 14:05 ·  日本 IIJ
新手上路
积分 2
发帖 2
注册 2010-03-15 18:20
16年会员
UID 162257
性别 男
状态 离线
刚刚接触bat,我想在文件中aaa.xml中查找出属性<abc>,并把<abc>的值由false改成true,如果本来就是true就保留。

也在网上学习了相关的写法:
for /f "tokens=*" %%a in ('findstr /i /n "(<abc>怎么写??)" aaa.xml‘) do (
set zf=%%a
set zf=!zf:^<abc^>=`!

for /f "tokens=1* delims=`" %%i in ("!zf!") do (
if "%%j" neq "" (
set jg=%%j
set zf=!zf:false=true!
)
)
(怎么把修改后的结果存回aaa.xml呢?)


新手上路,请大家多多指教,谢谢
2 发表于 2010-03-16 14:48 ·  中国 重庆 电信
版主
★★★★★
积分 9,023
发帖 5,017
注册 2007-05-31 19:39
19年会员
UID 89899
性别 男
状态 离线
xml的内容贴出来看看
3 发表于 2010-03-16 14:59 ·  中国 江苏 苏州 太仓市 电信
银牌会员
★★★
积分 1,608
发帖 780
注册 2007-10-07 10:19
18年会员
UID 99089
性别 男
状态 离线
想返回结果还是比较麻烦的
4 xml 发表于 2010-03-16 15:07 ·  日本 IIJ
新手上路
积分 2
发帖 2
注册 2010-03-15 18:20
16年会员
UID 162257
性别 男
状态 离线
是jboss的配置文件,长我贴片段,还有特殊字符#,%,\,,.,_$
想把里面的 <attribute name="CallByValue">false</attribute> 改成true。

<?xml version="1.0" encoding="UTF-8"?>

<!-- $Id: jboss-service.xml 62434 2007-04-19 21:22:50Z dimitris@jboss.org $ -->

<!-- ===================================================================== -->
<!-- JBoss Server Configuration -->
<!-- ===================================================================== -->

<server>

<!-- Load all jars from the JBOSS_DIST/server/<config>/lib directory. This
can be restricted to specific jars by specifying them in the archives
attribute.
-->
<classpath codebase="${jboss.server.lib.url:lib}" archives="*"/>

<!-- ==================================================================== -->
<!-- JSR-77 Single JBoss Server Management Domain -->
<!-- ==================================================================== -->
<mbean code="org.jboss.management.j2ee.LocalJBossServerDomain"
name="jboss.management.local:j2eeType=J2EEDomain,name=Manager">
<attribute name="MainDeployer">jboss.system:service=MainDeployer</attribute
<attribute name="CallByValue">false</attribute>
<!-- The listening port for the bootstrap JNP service. Set this to -1
to run the NamingService without the JNP invoker listening port.
-->

<!-- Files starting with theses strings are ignored -->
<property name="prefixes">#,%,\,,.,_$</property>
<!-- Files ending with theses strings are ignored -->
<property name="suffixes">#,$,%,~,\,v,.BAK,.bak,.old,.orig,.tmp,.rej,.sh</property>
<!-- Files matching with theses strings are ignored -->

</attribute>
</mbean>

</server>

[ Last edited by thenea on 2010-3-16 at 15:12 ]
5 发表于 2010-03-16 17:03 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
积分 1,039
发帖 897
注册 2009-03-01 15:34
17年会员
UID 140302
性别 男
来自 在地狱中仰望天堂
状态 离线
fr aaa.xml /ric:"<attribute name=\"CallByValue\">false</attribute>" /t:"<attribute name=\"CallByValue\">ture</attribute>"


[ Last edited by Hanyeguxing on 2010-3-17 at 19:59 ]
论坛跳转: