tech:xml_xpath_parse
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| tech:xml_xpath_parse [2025/03/24 15:06] – créée - modification externe 127.0.0.1 | tech:xml_xpath_parse [2026/05/29 13:13] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # XML xpath parse | ||
| + | |||
| + | Il existe deux langages de requêtes XML : **XPath** et **XQuery**. | ||
| + | |||
| + | Voir aussi : | ||
| + | * xml_grep (xml-twig-tools), | ||
| + | |||
| + | |||
| + | |||
| + | ## Lint | ||
| + | |||
| + | ~~~bash | ||
| + | xmllint --noout fic.xml | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## xpath | ||
| + | |||
| + | ~~~bash | ||
| + | virsh dumpxml VM1 |xpath -q -e "/ | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Ansible | ||
| + | |||
| + | ### Exemple | ||
| + | |||
| + | `/ | ||
| + | ~~~xml | ||
| + | < | ||
| + | <policy domain=" | ||
| + | <policy domain=" | ||
| + | <policy domain=" | ||
| + | <policy domain=" | ||
| + | <policy domain=" | ||
| + | <policy domain=" | ||
| + | <!-- <policy domain=" | ||
| + | <policy domain=" | ||
| + | <policy domain=" | ||
| + | <policy domain=" | ||
| + | <policy domain=" | ||
| + | </ | ||
| + | ~~~ | ||
| + | |||
| + | Nous voulons ajouter | ||
| + | |||
| + | `/ | ||
| + | ~~~xml | ||
| + | < | ||
| + | <policy domain=" | ||
| + | </ | ||
| + | ~~~ | ||
| + | |||
| + | Conf Ansible | ||
| + | |||
| + | ~~~yaml | ||
| + | - name: install deps for ansible xml module | ||
| + | apt: name=' | ||
| + | vars: | ||
| + | packages: | ||
| + | - python-lxml | ||
| + | - python3-lxml # For Ansible xml | ||
| + | |||
| + | - name: / | ||
| + | xml: | ||
| + | path: / | ||
| + | xpath: / | ||
| + | attribute: value | ||
| + | value: " | ||
| + | ~~~ | ||
| + | |||
