dt1000
dt1000

Reputation: 3732

ruby search for name and value in nokogiri object

The code below will get me all nodes with name=visible, like this node:

<property name="visible" value="false"/>




  vis = @noko_obj.search("property[name=visible]")

...regardless of what value is. However, what if I want the nodes whose name="visible" AND whose value="true"?

thanks

Upvotes: 0

Views: 480

Answers (1)

mu is too short
mu is too short

Reputation: 434945

Just add another attribute selector:

vis_true = @noko_obj.search('property[name=visible][value=true]')

The order of the attribute selectors doesn't matter so you could also do this:

vis_true = @noko_obj.search('property[value=true][name=visible]')

Upvotes: 1

Related Questions