How to match the brother of a certain XML element in ruby?

I played around with nokogiri in ruby and the XML searching feature, e.g.:

a = Nokogiri.XML(open 'a.xml')
x ='//div[@class="foo"]').text

which works quite nice.

But how can I specify to match the next (brother) element on the same level (and only the next)?

For example for this input:

  <div class="foo"></div>
  <div>EXTRACT ME</dev>

The actual input is some non-XHTML html, but so far Nokogiri.XML does not complain.

Btw, what filter syntax actually expects? xpath?


Taking the hint from Brian Agnew and DevNull I guess that actually expects xpath syntax and using the following-sibling predicate the following expression matches what was asked:

a ='//div[@class="foo"]/following-sibling::div[1]')

I think you want XPath's following-sibling predicate.

Need Your Help Chat on Dreamhost: Hiding the URL

node.js dreamhost

My chat is accessible through the URL Dreamhost does not allow us to bind 80, so I am binding it on 8080.

xlrd library not working with xlsx files.any way to covert xlsx to xls using python?

python excel xls xlsx xlrd

I want to convert xlsx file to xls format using python. The reason is that im using xlrd library to parse xls files, but xlrd is not able to parse xlsx files.