URL: https://linuxfr.org/forums/general-cherche-logiciel/posts/xmllint-ou-parser-un-xml-avec-xpath-en-shell Title: XMLLINT ou Parser un XML avec XPath en Shell Authors: Elodie Date: 2010年04月19日T21:21:23+02:00 Tags: Score: 0 Bonsoir, J'utilise depuis peu un logiciel en Shell pour parser une URL XML et obtenir une valeur suivant un path. Ce logiciel fonctionné très bien (avec quelques réglages sed pour nettoyer le résultat. Cependant, sans rien avoir changé de mon fichier XML ni de ma ligne Shell, ca ne fonctionne plus. J'utilise xmllint pour parser ce fichier par cette manière : echo "cat mod_cband/Users/mick/usages/total" | xmllint [http://localhost/cband-status?xml](http://localhost/cband-status?xml) Où 'mick' est un User et l'adresse HTTP, le lien pour accéder aux données d'un trafic Web monitoré par cband (un module Apache). Voici ce que xmllint me retourne maintenant : [http://localhost/cband-status?xml:216:](http://localhost/cband-status?xml:216:) parser error : StartTag: invalid element name £spaces£ £/spaces£<54321.franceserv.com> £spaces£ £/spaces£^ [http://localhost/cband-status?xml:234:](http://localhost/cband-status?xml:234:) parser error : expected '>' £spaces£ £/spaces£54321.franceserv.com> £spaces£ £/spaces£^ [http://localhost/cband-status?xml:234:](http://localhost/cband-status?xml:234:) parser error : Opening and ending tag mismatch: Virtualhosts line 6 and unparseable £spaces£ £/spaces£54321.franceserv.com> £spaces£ £/spaces£^ [http://localhost/cband-status?xml:4339:](http://localhost/cband-status?xml:4339:) parser error : StartTag: invalid element name £spaces£ £/spaces£<9ruedecarras.franceserv.com> £spaces£ £/spaces£^ [http://localhost/cband-status?xml:4357:](http://localhost/cband-status?xml:4357:) parser error : expected '>' £spaces£ £/spaces£9ruedecarras.franceserv.com> £spaces£ £/spaces£^ [http://localhost/cband-status?xml:4357:](http://localhost/cband-status?xml:4357:) parser error : Opening and ending tag mismatch: mod_cband line 2 and unparseable £spaces£ £/spaces£9ruedecarras.franceserv.com> £spaces£ £/spaces£^ [http://localhost/cband-status?xml:4357:](http://localhost/cband-status?xml:4357:) parser error : Extra content at the end of the document £spaces£ £/spaces£9ruedecarras.franceserv.com> Il semble bloquer lorsque les balises XML débutent par un nombre. J'ai fais l'essai pour générer cette config XML avec une lettre et ainsi, fausser le 'ServerName' ainsi que les identifiants et ca marche ... Mais plus rien ne fonctionne au niveau Apache étant donné que les 'ServerName' (adresse Web) ne sont plus les mêmes. Modifier ce fichier de cette manière à chaque parse XML est possible mais c'est une perte de temps incroyable. Le plus étrange est que j'ai toujours eux des adresses commendant par des nombres et que xmllint n'a jamais toussé. Deux questions : - Avez vous une solution à xmllint ? - Auriez vous une autre application (non pas pour valider le xml comme le fait xmllint) mais un parseur XML XPath en Shell ? Merci d'avance