1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-06-16 04:47:30 +00:00
community.general/tests/integration/targets/xml_info/tasks/test-xmlstring.yml
shreyash bhosale 91ef50cef7 add xml_info module with shared module_utils and doc fragment
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-04 18:31:19 +05:30

43 lines
1.1 KiB
YAML

---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Count nodes in an XML string
xml_info:
xmlstring: "{{ xml_info_test_xml }}"
xpath: /business/beers/beer
count: true
register: count_result
- name: Test expected result
assert:
that:
- count_result is not changed
- count_result.count == 3
- name: Get element text from an XML string
xml_info:
xmlstring: "{{ xml_info_test_xml }}"
xpath: /business/rating
content: text
register: text_result
- name: Test expected result
assert:
that:
- text_result is not changed
- text_result.matches[0]['rating'] == '10'
- name: Print match from an XML string
xml_info:
xmlstring: "{{ xml_info_test_xml }}"
xpath: /business/beers/beer
print_match: true
register: match_result
- name: Test expected result
assert:
that:
- match_result is not changed
- match_result.matches | length == 3