I'm trying to parse an RDF file based on the old Mozilla extension format to get the version, for use in a makefile, so looking for xmllint
or similar aproaches. .
<?xml version="1.0" encoding="UTF-8"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest"
em:id="some ID" em:version="1.0"
em:name="somename"
em:description="description"
em:creator="author"
em:iconURL="chrome://extension/skin/icon.png"
em:unpack="false" em:type="2" />
<em:targetApplication name="Pale Moon">
<Description
em:id="{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}"
em:minVersion="28.0.0a1"
em:maxVersion="29.*" />
</em:targetApplication>
</RDF>
How do I extract the em: elements that are nested within a Description tag (id and version mainly)? Or should I not use this altogether and use regex - but again how on the commandline? I've found references to xmllint and xmlstarlet here, but couldn't figure it out.
Edit, tried the following commandline with xmlstarlet, but it doesn't output anything.
xmlstarlet sel -N r=http://www.w3.org/1999/02/22-rdf-syntax-ns# -N em=http://www.mozilla.org/2004/em-rdf# -t -m "/r:RDF/r:Description/@em:version" install.rdf