Reputation: 1141
I'm trying to extract the temperature value (70°F) from a section of xml using xmlstartlet
: <variable var='T' description='Temp' unit='F' value='70'/>
XML Text (output.xml)
<station id="KBOS" name="Boston, Logan International Airport" elev="20" lat="42.36056" lon="-71.01056" provider="NWS/FAA">
<ob time="25 Jul 7:05 am" utime="1564052700">
<variable var='T' description='Temp' unit='F' value='70'/>
Attempted Code
xmlstarlet sel -T -t -m '/var='T'/description='Temp'/value=' -v . -n output.xml
What am I missing?
Upvotes: 0
Views: 85
Reputation: 52888
It's hard to say for sure since your XML isn't a well-formed example, but try this:
xmlstarlet sel -T -t -m "//variable[@var='T'][@description='Temp']/@value" -v . input.xml
Upvotes: 1