Returns the value of the matched xpath element CLI Example: .. code-block:: bash salt '*' xml.get_value /tmp/test.xml ".//element"
(file, element)
| 22 | |
| 23 | |
| 24 | def 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 | |
| 43 | def set_value(file, element, value): |