Board logo

标题: 【新手求助】查找并替换文件中字符串 [打印本页]

作者: thenea     时间: 2010-3-16 14:05    标题: 【新手求助】查找并替换文件中字符串
刚刚接触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呢?)


新手上路,请大家多多指教,谢谢

作者: HAT     时间: 2010-3-16 14:48
xml的内容贴出来看看

作者: huahua0919     时间: 2010-3-16 14:59
想返回结果还是比较麻烦的

作者: thenea     时间: 2010-3-16 15:07    标题: 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 ]

作者: Hanyeguxing     时间: 2010-3-16 17:03
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 ]