Hi, I am trying to delete an element in a namespace xml based on element value ; without namespace, deletion is working fine (as posted in ansible documentation of xml module)… Can someone help, please
Example 1: xml with no namespace
Tasty Hot Coffee
<key_name>
cold brew
cappuccino
mochai
</key_name>
10
http://tastyhotcoffee.com
---------- It worked ------------
ansible localhost -m xml -a “path=xml_example.xml xpath=‘/business/key_name/type[text()="mocha"]’ state=absent”
localhost | CHANGED => {
“actions”: {
“namespaces”: {},
“state”: “absent”,
“xpath”: “/business/key_name/type[text()="mocha"]”
},
“changed”: true
}
---------- It worked ------------
Example 1: xml with namespace
Tasty Hot Coffee
<key_name>
cold brew
cappuccino
mochai
</key_name>
10
http://tastyhotcoffee.com
---------- It did not work------------
ansible localhost -m xml -a “path=xml_example.xml xpath=‘x:/business/x:key_name/x:type[text()="mochai"]’ namespaces=‘x="https://coffee.com"’”
localhost | FAILED! => {
“changed”: false,
“msg”: “Syntax error in xpath expression: x:/business/x:key_name/x:type[text()="mochai"] (Invalid expression)”
}