diff --git a/plugins/plugin_utils/from_xml.py b/plugins/plugin_utils/from_xml.py index eb1194e..c261629 100644 --- a/plugins/plugin_utils/from_xml.py +++ b/plugins/plugin_utils/from_xml.py @@ -44,7 +44,7 @@ def from_xml(data, engine): if not HAS_XMLTODICT: _raise_error("Missing required library xmltodict") try: - res = xmltodict.parse(data) + res = xmltodict.parse(data, dict_constructor=dict) except Exception: _raise_error("Input Xml is not valid") return res diff --git a/tests/integration/targets/utils_from_xml/tasks/simple.yaml b/tests/integration/targets/utils_from_xml/tasks/simple.yaml index edc529e..aae1074 100644 --- a/tests/integration/targets/utils_from_xml/tasks/simple.yaml +++ b/tests/integration/targets/utils_from_xml/tasks/simple.yaml @@ -19,10 +19,12 @@ - name: Integration tests with and without default engine as xmltodict and ansible.builtin.assert: - that: "{{ output == item.test }}" + that: "{{ output == test_item.test }}" loop: - test: "{{ data | ansible.utils.from_xml() }}" - test: "{{ data | ansible.utils.from_xml('xmltodict') }}" + loop_control: + loop_var: test_item - name: Setup invalid xml as input to ansible.utils.from_xml. ansible.builtin.set_fact: