中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟
中国DOS联盟论坛
现在时间是 2026-08-12 13:39
47,811 主题排行 / 349,897 发帖 / 今日 0 篇 / 48,256 会员排行
DOS批处理 & 脚本技术(批处理室) » 【新手求助】查找并替换文件中字符串
可打印版本  1,060 / 4
第1楼 thenea 发表于 2010-03-16 14:05
新手上路 发帖 2 积分 2
【新手求助】查找并替换文件中字符串
刚刚接触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楼 HAT 发表于 2010-03-16 14:48
版主 发帖 5,017 积分 9,023
xml的内容贴出来看看
第3楼 huahua0919 发表于 2010-03-16 14:59
银牌会员 发帖 780 积分 1,608
想返回结果还是比较麻烦的
第4楼 thenea 发表于 2010-03-16 15:07
新手上路 发帖 2 积分 2
xml
是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楼 Hanyeguxing 发表于 2010-03-16 17:03
银牌会员 发帖 897 积分 1,039 来自 在地狱中仰望天堂


[ Last edited by Hanyeguxing on 2010-3-17 at 19:59 ]
[ 联系联盟系统管理团队 - 中国DOS联盟 - 标准版 ]
Sponsored by ifanr Inc | © 2001–2023