Created
August 19, 2014 15:10
-
-
Save kerphi/e6975df924bed2d774b6 to your computer and use it in GitHub Desktop.
Utilisation d'xmlstarlet pour supprimer d'un document XML des éléments ciblés par une liste de XPATH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo '<?xml version="1.0"?> | |
<xml> | |
<table> | |
<rec id="1"> | |
<numField>123</numField> | |
<stringField>String Value</stringField> | |
</rec> | |
<rec id="2"> | |
<numField>346</numField> | |
<stringField>Text Value</stringField> | |
</rec> | |
<rec id="3"> | |
<numField>-23</numField> | |
<stringField>stringValue</stringField> | |
</rec> | |
</table> | |
</xml>' | xmlstarlet ed -d "/xml/table/rec[@id='2']" -d "/xml/table/rec[@id='1']" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
En terme de perf, sur ma machine locale, l'exécution de 100 nettoyage à coup de XPATH sur le fichier témoin d'ECCO (qui pèse 5Mo) prend 14 secondes.
Cf la ligne de commande utilisée :