开发者

Get div attributes via Hpricot

开发者 https://www.devze.com 2023-02-25 20:06 出处:网络
I\'ve got a spec开发者_开发百科ific div id called progress_bar () And I\'m trying to retrieve just the width of the div. I\'m fairly new to Ruby and Hpricot so any help would be greatly appreciated.

I've got a spec开发者_开发百科ific div id called progress_bar ()

And I'm trying to retrieve just the width of the div. I'm fairly new to Ruby and Hpricot so any help would be greatly appreciated.

Cheers, Scott


As long as the width attribute is set in the HTML something like this should work according to the docs:

doc = Hpricot("my html")
(doc/"#progress_bar")['width']

Found here: https://github.com/hpricot/hpricot

0

精彩评论

暂无评论...
验证码 换一张
取 消