How to download images from an xml feed using terminal? How can I download png images from an xml feed that looks the following way?

&lt;ListBucketResult xmlns="http://url1.com"&gt;
  &lt;Name&gt;imagesToUse&lt;/Name&gt;
&lt;Prefix/&gt;
&lt;Marker/&gt;
&lt;IsTruncated&gt;false&lt;/IsTruncated&gt;
&lt;Contents&gt;
  &lt;ImageStuff&gt;imagetodownload.png&lt;/ImageStuff&gt;
  &lt;Size&gt;17293&lt;/Size&gt;
&lt;/Contents&gt;


I was taking a look at this question on here about the same topic, except that I don't need to rename them, just download them.

Being new to shell scripts, I'm not quite sure how to do this (although I can definitely do this in 2 minutes in objective-c).

I have tried creating the following script and running bash myscript.sh

#!/bin/bash
URL='https://theurlwiththexml.com'
i=0
for u in $(curl -s "$URL" |
           grep png | 
           sed -E 's/.*&lt;ImageStuff&gt;(.+)&lt;\/ImageStuff&gt;/\1/'); do
    curl -s "$u" -o $i.png
    (( i++ ))
done


But nothing happens. It just prints another line without errors.
After curl http://theurlwiththexml.com:

sed -n 's,.*&lt;ImageStuff&gt;\(.*\.png\)&lt;.*,\1,p'|xargs -I, curl http://url1.com/, -o ,


sed -n disables printing, \( and \) are a portable way to specify groups, and p prints the pattern space. xargs -I specifies a replacement string and curl -o specifies an output file.

Or using xmlstarlet, parallel, and wget:

xml sel -t -v //ImageStuff|parallel wget http://url1.com/{}


sel is an abbreviation for select, -t -v uses the value template, and //ImageStuff is an XPath expression that matches all ImageStuff nodes.