I want to insert an element in the XML.
This is an XML file - named web.xml
<web-app>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
This is the ANT task I am using to insert an element in the web-app node.
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpath="C:/xmltask.jar"/>
<xmltask source="C:\web.xml" dest="C:\web.xml>
<insert path="/web-app">
<![CDATA[
<hello_world id="3">hello world</hello_world>
]]>
</insert>
</xmltask>
Ant 任务运行在web-app中插入hello_world节点。
The insert (actually root node selection) fails when the root has an attribute.
So the xmltask insert doesn't work when the XML is -
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee">
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
I tried to use insert like this, but no luck -
<insert path="/web-app/[@xmlns='http://xmlns.jcp.org/xml/ns/javaee']">
选择根节点的方法是什么?为什么这不起作用,解释会有所帮助。