MCPcopy Index your code
hub / github.com/saltstack/salt / get_attribute

Function get_attribute

salt/modules/xml.py:64–80  ·  view source on GitHub ↗

Return the attributes of the matched xpath element. CLI Example: .. code-block:: bash salt '*' xml.get_attribute /tmp/test.xml ".//element[@id='3']"

(file, element)

Source from the content-addressed store, hash-verified

62
63
64def get_attribute(file, element):
65 """
66 Return the attributes of the matched xpath element.
67
68 CLI Example:
69
70 .. code-block:: bash
71
72 salt '*' xml.get_attribute /tmp/test.xml ".//element[@id='3']"
73 """
74 try:
75 root = ET.parse(file)
76 element = root.find(element)
77 return element.attrib
78 except AttributeError:
79 log.error("Unable to find element matching %s", element)
80 return False
81
82
83def set_attribute(file, element, key, value):

Callers

nothing calls this directly

Calls 3

findMethod · 0.80
parseMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected