Xmlstarlet在更新xml时使用--inplace选项

时间:2013-08-02 09:49:41

标签: xml xmlstarlet

我试图使用--inplace global选项更新一个xml标签,如下所示

 xml ed  --inplace -N x="http://java.sun.com/xml/ns/j2ee" -u "//x:web-app/x:filter/x:init-param/x:param-value" -v "/cuadmin/showRecovery.do" WEB-INF/web.xml 

上面给我的错误

**I/O warning : failed to load external entity "x=http%3A//java.sun.com/xml/ns/j2ee"**

我试图修改的xml如下所示: -

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <filter>
    <filter-name>recoveryRedirectFilter</filter-name>
    <filter-class>ClassName</filter-class>
    <init-param>
      <param-name>somename</param-name>
      <param-value>Someurl.do</param-value>
    </init-param>
  </filter>
</web-app>

1 个答案:

答案 0 :(得分:3)

--inplace选项仅在1.0.2中添加

xml ed -N x="http://java.sun.com/xml/ns/j2ee" -u "//x:web-app/x:filter/x:init-param/x:param-value" -v "/cuadmin/showRecovery.do" WEB-INF/web.xml > WEB-INF/tmp-web.xml
mv WEB-INF/tmp-web.xml WEB-INF/web.xml