You need an XML parser to handle XML, but getting
XmlStarlet to extract the URLs is not quite as straight forward as it could be...
Code:
$ xmlstarlet select -t -v '/_:metalink/_:file/_:url' -n input.xml
https://scihub.copernicus.eu/dhus/odata/v1/Products('80ba113d-b5c5-4f4f-8e4e-3231bd2c2859')/$value
https://scihub.copernicus.eu/dhus/odata/v1/Products('d0d43133-8089-4ec9-ab35-37d26323af63')/$value
https://scihub.copernicus.eu/dhus/odata/v1/Products('cefbc29e-f567-4410-b0b3-860617cf6a19')/$value
https://scihub.copernicus.eu/dhus/odata/v1/Products('63e2415f-249c-4d68-a908-d26efc34bf82')/$value
https://scihub.copernicus.eu/dhus/odata/v1/Products('c7de7226-5769-451d-9348-b8bf85e7b93f')/$value
https://scihub.copernicus.eu/dhus/odata/v1/Products('13168064-4914-4320-aecc-2482b7f9d005')/$value
Where input.xml is a file containing your code, but with the missing "
</metalink>" appended. (You could instead from stdin.)
See "
xmlstarlet select --help" (or
online user guide) for explanation of the syntax (which does
not follow typical command-line conventions).
The "
_:" bit in the XPath expression is required due to the xmlns attribute on the root element.
Without a xmlns it would just be "
/metalink/file/url" (and trying to use _: there results in an "Undefined namespace prefix" error.)
If there might be other "url" tags outside of "file" tags, you could use:
Code:
$ xmlstarlet select -t -v '//_:url' -n input.xml
The output of both is a newline-delimited list, which can be
looped in the usual way and passed to wget/curl/whatever.
The "
-n" is needed to output a trailing newline at the end, which some command-line tools are picky about.