Maven打包中用xpath替换的语法说明

来源:互联网 发布:上海至寻网络怎么样 编辑:程序博客网 时间:2024/06/05 20:44
  <bean id="myPropertyConfigurer"  class="com.jader.common.DecryptPropertyPlaceholderConfigurer">                 <property name="locations" value="classpath:config.properties" />                     <property name="fileEncoding" value="UTF-8"/>                 <property name="keyLocation" value="classpath:key.key" />       </bean>    <bean id="conf"  class="com.jader.common.DecryptPropertyPlaceholderConfigurer">                 <property name="locations">            <list>                <value>classpath:jdbc.properties</value>            </list>        </property>                     <property name="fileEncoding" value="UTF-8"/>                 <property name="keyLocation" value="classpath:key.key" />   

以上面的xml文件为例:
XPath 使用路径表达式在 XML 文档中选取节点。节点是通过沿着路径或者 step 来选取的。
下面列出了最有用的路径表达式:
这里写图片描述

例如:我替换classpath:config.properties<replace xpath="/beans/bean[@id=myPropertyConfigurer]/property[@name=locations]/@value">classpath:config_test.propertis</replace>替换class:jdbc.properties<replace xpath="/beans/bean[@id=conf]/property[@name=locations]/list/value">classpath:config_test.propertis</replace>

选取未知节点
XPath 通配符可用来选取未知的 XML 元素。
这里写图片描述
实例
在下面的表格中,我们列出了一些路径表达式,以及这些表达式的结果:
这里写图片描述
xpath表达式在线验证:http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm

1 0
原创粉丝点击