# xml module don't keep the xml nested child structure in the result

**URL:** <https://forum.ansible.com/t/xml-module-dont-keep-the-xml-nested-child-structure-in-the-result/35727>\
**Category:** Ansible Project\
**Created:** [September 12, 2021, 1:43pm UTC](https://forum.ansible.com/t/xml-module-dont-keep-the-xml-nested-child-structure-in-the-result/35727 "2021-09-12T13:43:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruno1](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@Bruno1](https://forum.ansible.com/u/Bruno1)\
**Post date:** [September 12, 2021, 1:43pm UTC](https://forum.ansible.com/t/xml-module-dont-keep-the-xml-nested-child-structure-in-the-result/35727/1 "2021-09-12T13:43:58Z")

</div>

Hi,  
I’m trying to use the xml module to find a xml block.  
The xpath find the block, but all nested child structure is removed, I.E all data is at same level after.  
Has anyone any ideas what is missing?  
Wrong module to use?

tasks:

- name: manage xml block  
xml:  
path: “output/{{ inventory\_hostname }}\_get\_config.xml”  
xpath: /root/groups[name=“test”]//\*  
content: text  
register: test

- name: Print result xml  
debug:  
msg: "{{ test.matches}} "

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 12, 2021, 2:10pm UTC](https://forum.ansible.com/t/xml-module-dont-keep-the-xml-nested-child-structure-in-the-result/35727/2 "2021-09-12T14:10:36Z")

</div>

Hard to say without any actual xml content

---

<div class="post-metadata">

**Author:** ![Bruno1](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@Bruno1](https://forum.ansible.com/u/Bruno1)\
**Post date:** [September 12, 2021, 3:15pm UTC](https://forum.ansible.com/t/xml-module-dont-keep-the-xml-nested-child-structure-in-the-result/35727/3 "2021-09-12T15:15:33Z")

</div>

Hi,  
Here comes an example:

test test any any any test2 0 0 254 1 128

The output is :

“matches”: [  
{  
“name”: “test”  
},  
{  
“security”: null  
},  
{  
“policies”: null  
},  
{  
“global”: null  
},  
{  
“policy”: null  
},  
{  
“name”: “test”

…  
…  
…

söndag 12 september 2021 kl. 16:11:01 UTC+2 skrev [dick....@geant.org](mailto:dick....@geant.org):
