From 6e7cf7377b3bae619deb5ecb6337433987b5f538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Stankovi=C4=87?= Date: Sun, 13 Aug 2017 05:04:35 +0200 Subject: [PATCH] xml: Add example with namespaces and clarify note (#28113) * xml: Add example with namespaces and clarify note * Correct the line length --- lib/ansible/modules/files/xml.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/ansible/modules/files/xml.py b/lib/ansible/modules/files/xml.py index f6b6df4f44..0a9367bac8 100755 --- a/lib/ansible/modules/files/xml.py +++ b/lib/ansible/modules/files/xml.py @@ -110,6 +110,7 @@ requirements: notes: - This module does not handle complicated xpath expressions, so limit xpath selectors to simple expressions. - Beware that in case your XML elements are namespaced, you need to use the C(namespaces) parameter. +- Namespaces prefix should be used for all children of an element where namespace is defined, unless another namespace is defined for them. author: - Tim Bielawa (@tbielawa) - Magnus Hedemark (@magnus919) @@ -177,6 +178,26 @@ EXAMPLES = r''' path: /foo/bar.xml xpath: /business/website children: [] + +# In case of namespaces, like in below XML, they have to be explicitely stated +# Note: there's the prefix "x" in front of the "bar", too +# +# +# +# +# +# + +- name: Set namespaced '/x:foo/x:bar/y:baz/@z:my_namespaced_attribute' to 'false' + xml: + path: foo.xml + xpath: /x:foo/x:bar/y:baz + namespaces: + x: http://x.test + y: http://y.test + z: http://z.test + attribute: z:my_namespaced_attribute + value: "false" ''' RETURN = r'''