1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-05-11 04:04:13 +00:00

xml: fix print_match not populating matches return value (#12013)

* fix(xml): populate matches when print_match is set, fix returned doc

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(xml): add integration tests for print_match

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* changelog: add fragment for PR 12013

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexei Znamensky 2026-05-10 11:41:37 +12:00 committed by GitHub
parent b8659f5c61
commit abef8f2aed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 43 additions and 2 deletions

View file

@ -355,7 +355,7 @@ count:
matches:
description: The xpath matches found.
type: list
returned: when parameter O(print_match) is set
returned: when parameter O(print_match) is set, or when parameter O(content) is set
xmlstring:
description: An XML string of the resulting output.
type: str
@ -412,7 +412,7 @@ def do_print_match(module, tree, xpath, namespaces):
match_xpaths.append(tree.getpath(m))
match_str = json.dumps(match_xpaths)
msg = f"selector '{xpath}' match: {match_str}"
finish(module, tree, xpath, namespaces, changed=False, msg=msg)
finish(module, tree, xpath, namespaces, changed=False, msg=msg, matches=match_xpaths)
def count_nodes(module, tree, xpath, namespaces):