to parse really simple xml like:

    <tag>
     <tag1>VALUE</tag1>
    </tag>

    i wrote a function and placed it in my .bashrc…

    # simple XML/HTML parse function
    # used to extrace values from a really simple result.xml file.
    # 
    # use like this:
    # while rdom; do
    #  if [[ $TAG = "TAG-Name-Im-Looking-For" ]]; then
    #     echo $VAL;
    #  fi;
    # done < /home/user/results.xml
    #
    rdom() {
       export TAG; export VAL;
       local IFS=\> ;
       read -d \< TAG VAL ;
    }

    To parse more complex XML files use XPATH or similar.

    Leave a Reply