I have the following xml file:
<background>
<starttime>
<year>2021</year>
<month>01</month>
<day>22</day>
<hour>15</hour>
<minute>59</minute>
<second>54</second>
</starttime>
<static>
<duration>10000000000.0</duration>
<file>
<size width="1" height="1">A</size>
</file>
</static>
</background>
I would like to set the 'width' attribute of the 'size' node. So far I have the following ansible code:
- name: Set the attribute 'width' of size
xml:
path: "some.xml"
xpath: "{{ item.xpath }}"
value: "{{ item.value }}"
with_items:
- { xpath: "/background/static/file/size/@width", value: "1920" }
This gives me the error:
"Xpath /background/static/file/size/@width does not reference a node!"
I saw similar questions, but none had helped me. I am pretty sure that my xpath expression is correct. My question, is how to set the attribute using ansible xml?
question from:
https://stackoverflow.com/questions/65887279/set-xml-node-attribute-using-ansible-xml-module 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…