0

In the following XML file, I would like to extract the value 300.

<Cube>
    <Cube time="Test">
        <data name="value">300</data>
    </Cube>
</Cube>

I tried the following code but it doesn't seem to be working.

xidel 1.xml -e "css('Cube[time=Test] data[name=value]')/@value"

How would I extract the value?

Jeroen
  • 15,257
  • 12
  • 59
  • 102
Arun
  • 23
  • 1
  • 5

1 Answers1

1

You don't need the trailing /@value, omit it and your command should return the value 300 fine :

xidel 1.xml -e "css('Cube[time=Test] data[name=value]')"

or using equivalent XPath expression :

xidel 1.xml -e "/Cube/Cube[@time='Test']/data[@name='value']"
har07
  • 88,338
  • 12
  • 84
  • 137