MCPcopy
hub / github.com/saltstack/salt / get_value

Function get_value

salt/modules/xml.py:24–40  ·  view source on GitHub ↗

Returns the value of the matched xpath element CLI Example: .. code-block:: bash salt '*' xml.get_value /tmp/test.xml ".//element"

(file, element)

Source from the content-addressed store, hash-verified

22
23
24def get_value(file, element):
25 """
26 Returns the value of the matched xpath element
27
28 CLI Example:
29
30 .. code-block:: bash
31
32 salt '*' xml.get_value /tmp/test.xml ".//element"
33 """
34 try:
35 root = ET.parse(file)
36 element = root.find(element)
37 return element.text
38 except AttributeError:
39 log.error("Unable to find element matching %s", element)
40 return False
41
42
43def set_value(file, element, value):

Callers

nothing calls this directly

Calls 3

findMethod · 0.80
parseMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected