Thursday, August 23, 2018

xmlstarlet & xidel, xml parsing from the command line

 

For xml parsing from the command line, xmlstartlet and xidel require the ‘-‘ switch at the end to read from stdin. This has to be used during piping

 

curl http://gist.bbldtl.int:9000/ema/HUBQ1\?page\=log\&message_id\=52285748 | xidel -e '//pre' -   

image

 

 

Or:

curl http://gist.bbldtl.int:9000/ema/HUBQ1\?page\=log\&message_id\=52285748 | xmllint --format --xpath '//pre' - 

 

image

xidel removes the enclosing tags by default. So that’s better.

No comments:

Post a Comment