Hi,
Here  comes an example:

    <root>
            <groups>
                <name>test</name>
                <security>
                    <policies>
                        <global>
                            <policy>
                                <name>test</name>
                                <match>
                                    <source-address>any</source-address>
                                    
<destination-address>any</destination-address>
                                    <application>any</application>
                                </match>
                                <then>
                                    <permit>
                                    </permit>
                                </then>
                            </policy>
                        </global>
                    </policies>
                </security>
            </groups>
            <groups>
                <name>test2</name>
                <chassis>
                    <cluster>
                        <redundancy-group>
                            <name>0</name>
                            <node>
                                <name>0</name>
                                <priority>254</priority>
                            </node>
                            <node>
                                <name>1</name>
                                <priority>128</priority>
                            </node>
                        </redundancy-group>
                    </cluster>
                </chassis>
            </groups>
    </root>

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 [email protected]:

> Hard to say without any actual xml content
>
> On Sun, 12 Sep 2021 at 15:44, Bruno1 <[email protected]> wrote:
>
>> 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}} "
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/64b258ce-b464-460a-b5d4-d06551f7ef73n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/64b258ce-b464-460a-b5d4-d06551f7ef73n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b449224a-e0bc-43cb-b112-6daaa24a11dbn%40googlegroups.com.

Reply via email to