Multiple search with Hpricot
Had RTFM'ed, but still puzzled. I need to get objects which satisfy at least one of the pr开发者_Go百科operty condition list.
E.g. divs, where class == "marked" OR class = "data" OR class = "comments"
For now emulated it manually, but is it possible with Hpricot standard abilities?
doc = Hpricot.parse(..your data...)
divs = doc.search("//div[@class='marked' or @class='data' or @class='comments']")
The search
takes an xpath expression, and xpath allows logical and
and or
operators. See this great answer about a similar question: XPATH Multiple Element Filters.
精彩评论