HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/xml.cpython-310.pyc
o

�N�g��@sXdZddlZddlmmZe�e�ZdZ	dd�Z
dd�Zdd	�Zd
d�Z
dd
�ZdS)z*
XML file manager

.. versionadded:: 3000
�NZxmlcCstS)zE
    Only load the module if all modules are imported correctly.
    )�__virtualname__�rr�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/xml.py�__virtual__srcC�>zt�|�}|�|�}|jWStyt�d|�YdSw)z�
    Returns the value of the matched xpath element

    CLI Example:

    .. code-block:: bash

        salt '*' xml.get_value /tmp/test.xml ".//element"
    �"Unable to find element matching %sF)�ET�parse�find�text�AttributeError�log�error��file�element�rootrrr�	get_value�


�rcCsRzt�|�}|�|�}Wntyt�d|�YdSwt|�|_|�|�dS)z�
    Sets the value of the matched xpath element

    CLI Example:

    .. code-block:: bash

        salt '*' xml.set_value /tmp/test.xml ".//element" "new value"
    rFT)	rr	r
rr
r�strr�write)rr�valuerZrelementrrr�	set_value+s

�

rcCr)z�
    Return the attributes of the matched xpath element.

    CLI Example:

    .. code-block:: bash

        salt '*' xml.get_attribute /tmp/test.xml ".//element[@id='3']"
    rF)rr	r
Zattribrr
rrrrr�
get_attribute@rrcCsXzt�|�}|�|�}Wntyt�d|�YdSw|�|t|��|�|�dS)z�
    Set the requested attribute key and value for matched xpath element.

    CLI Example:

    .. code-block:: bash

        salt '*' xml.set_attribute /tmp/test.xml ".//element[@id='3']" editedby "gal"
    rFT)	rr	r
rr
r�setrr)rr�keyrrrrr�
set_attributeSs

�
r)�__doc__�loggingZxml.etree.ElementTreeZetreeZElementTreer�	getLogger�__name__r
rrrrrrrrrr�<module>s