2012-09-21 41 views
1

基本上我想更新一个XML标记中的值。 这是我的XMLAnt任务更新值

<?xml version="1.0" encoding="utf-8" standalone="no"?> 
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> 
    <application> ten</application> 
    <version>1</version> 
</appengine-web-app> 

我想从十应用程序标记值更改为一些其它的值,说三。我的代码是这样的

<target name="renameconfig" 
     description="Renaming config files"> 
<taskdef name="xmltask" 
      classname="com.oopsconsultancy.xmltask.ant.XmlTask"/> 
<xmltask source="war/WEB-INF/appengine-web.xml" dest="war/WEB-INF/appengine-web.xml"> 
    <replace path="/:appengine-web-app/:application/text()" withText="three"> </replace> 
</xmltask> 
    </target> 

这填充应用程序标记.ie中的空值。如果有人纠正这一点,这将是非常棒的。感谢很多。

回答

0

的XPath的应该是:

<replace path="/appengine-web-app/application/text()" withText="three"> </replace> 

,或者如果命名空间在作祟:

<replace path="/*[namespace-uri()='http://appengine.google.com/ns/1.0' and local-name()='appengine-web-app']/*[namespace-uri()='http://appengine.google.com/ns/1.0' and local-name()='application']/text()" withText="three"> </replace> 
+0

IL尝试上面.thanks – user1689117

0
<replace path="/appengine-web-app/application/text()" withText="three"> </replace> 

这个什么都不会发生。

<replace path="/*[namespace-uri()='http://appengine.google.com/ns/1.0' and local-name()='appengine-web-app']/*[namespace-uri()='http://appengine.google.com/ns/1.0' and local-name()='application']/text()" withText="three"> </replace> 

值设置为空

+0

我想你贴到我的答案评论,作为一个答案。 –