'Ansible - modify xml with namespaces using community.windows.win_xml

Is it possible to modify xml with namespace using community.windows.win_xml? For example is it possible to add new node under welcome-file-list in XML:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

In docs is info "Namespace, processing-instruction, command and document node types cannot be modified with this module." but I'm not sure if I can't use namespaces or I can't only modify them.

I can add node under web-app node using

- name: Update web.xml
      community.windows.win_xml:
        path: "{{ webxml_path }}"
        xpath: /*
        fragment: "<new-node></new-node>"

but adding node under welcome-file-list doesn't work

- name: Update web.xml
      community.windows.win_xml:
        path: "{{ webxml_path }}"
        xpath: /web-app/welcome-file-list
        fragment: "<new-node></new-node>"

After deleting attribute xmlns from XML everything works.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source