Arun
Arun

Reputation: 23

Using Xidel how to extract value from xml file

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?

Upvotes: 0

Views: 1435

Answers (1)

har07
har07

Reputation: 89305

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']"

Upvotes: 1

Related Questions