# Win\_xml help cannot edit attributes

**URL:** <https://forum.ansible.com/t/win-xml-help-cannot-edit-attributes/42333>\
**Category:** Get Help\
**Tags:** windows, xml\
**Created:** [May 1, 2025, 4:19pm UTC](https://forum.ansible.com/t/win-xml-help-cannot-edit-attributes/42333 "2025-05-01T16:19:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akansible](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@akansible](https://forum.ansible.com/u/akansible)\
**Post date:** [May 1, 2025, 4:19pm UTC](https://forum.ansible.com/t/win-xml-help-cannot-edit-attributes/42333/1 "2025-05-01T16:19:49Z")

</div>

I am trying to use win\_xml module. Xml file is simple as following

```auto
<?xml version="1.0" encoding="UTF-8"?>
<config>
  <setting name="mode" value="development"/>
  <setting name="timeout" value="30"/>
</config>

```

* * *

Play is

```auto
tasks:
    - name: Set timeout to 60 seconds
      win_xml:
        path: C:\temp\sample.xml
        xpath: /config/setting[@name='timeout']
        attribute: value
        value: '60'
        state: present

```

* * *

What I get as an error

```auto
The full traceback is:
You cannot call a method on a null-valued expression.
At line:188 char:13
+ $candidate = $xmlorig.CreateElement($xmlfragment.get_Docu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvokeMethodOnNull

ScriptStackTrace:
at <ScriptBlock>, <No file>: line 188
fatal: [192.168.68.135]: FAILED! => {
    "changed": false,
    "msg": "Unhandled exception while executing module: You cannot call a method on a null-valued expression."

```

## } And I don’t understand why .

```auto
ansible [core 2.18.5]
  config file = None
  configured module search path = ['/home/ale/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ale/ansible/ansible/lib/python3.12/site-packages/ansible
  ansible collection location = /home/ale/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ale/ansible/ansible/bin/ansible
  python version = 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0] (/home/ale/ansible/ansible/bin/python3)
  jinja version = 3.1.6
  libyaml = True

```

* * *

`community.windows 2.4.0`

---

<div class="post-metadata">

**Author:** ![Lyle\_McKarns](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lyle_mckarns/32/8142_2.png) [@Lyle\_McKarns](https://forum.ansible.com/u/Lyle_McKarns)\
**Post date:** [May 1, 2025, 6:18pm UTC](https://forum.ansible.com/t/win-xml-help-cannot-edit-attributes/42333/2 "2025-05-01T18:18:50Z")

</div>

Based on a quick look at the [parameters](https://docs.ansible.com/ansible/latest/collections/community/windows/win_xml_module.html#parameters) section of the `win_xml` module doc it looks like you’re using `value` where the module is expecting `fragment`, and so `fragment` is a null-valued expression.

That’s where I’d start.

---

<div class="post-metadata">

**Author:** ![akansible](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@akansible](https://forum.ansible.com/u/akansible)\
**Post date:** [May 1, 2025, 6:47pm UTC](https://forum.ansible.com/t/win-xml-help-cannot-edit-attributes/42333/3 "2025-05-01T18:47:35Z")

</div>

Thank you 🙂  
Now it makes sense

```auto
tasks:
    - name: Set timeout to 60 seconds
      win_xml:
        path: C:\temp\sample.xml
        xpath: /config/setting[@name='timeout']
        attribute: value
        fragment: '60'
        type: attribute

```

And it worked could not understand it before 🙂
