以类似于这里的方式,我希望从sqlmap.config文件中获取xmlpoke connectionString:
<?xml version="1.0" encoding="utf-8" ?>
<sqlMapConfig
xmlns="http://ibatis.apache.org/dataMapper"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<database>
<provider name="oracleClient1.0"/>
<dataSource name="DSExtranetAdherent"
connectionString="Data Source=MyInstance;User ID=MyUser;Password=MyPwd;Unicode=True;"/>
</database>
</sqlMapConfig>我试着用这个戳:
<xmlpoke
file="${ConfigPath}\sqlmap.config"
xpath="/sqlMapConfig/database/dataSource/@connectionString"
value="${ConnectionString}" />但我收到一条错误信息:
'/sqlMapConfig/database/dataSource/@connectionString'.表达式XPath没有找到匹配的节点
当我移除xmlns属性时,xpath是有效的,但是我得到了这个运行时错误:
无法通过资源"SqlMap.config“作为资源加载文件。
知道如何用好的xpath修复这个xmlpoke吗?
发布于 2013-10-30 14:58:47
xmlns是默认的命名空间,xmlpoke需要一个前缀用于xpath解析:
<xmlpoke
file="${ConfigPath}\sqlmap.config"
xpath="/iba:sqlMapConfig/iba:database/iba:dataSource/@connectionString"
value="${ConnectionString}">
<namespaces>
<namespace prefix="iba" uri="http://ibatis.apache.org/dataMapper" />
</namespaces>
</xmlpoke>发布于 2013-10-30 13:49:55
应该为<namespaces>任务指定<xmlpoke>子节点:
<namespaces>
<namespace prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" />
</namespaces>本页上的最后一个示例只解释了你的案子。
https://stackoverflow.com/questions/19683629
复制相似问题