1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

xml: Add example with namespaces and clarify note (#28113)

* xml: Add example with namespaces and clarify note

* Correct the line length
This commit is contained in:
Marko Stanković 2017-08-13 05:04:35 +02:00 committed by Dag Wieers
parent 2aee9fb28a
commit 6e7cf7377b

View file

@ -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
#<?xml version='1.0' encoding='UTF-8'?>
#<foo xmlns="http://x.test" xmlns:attr="http://z.test">
# <bar>
# <baz xmlns="http://y.test" attr:my_namespaced_attribute="true" />
# </bar>
#</foo>
- 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'''