Class: OpenfireAdmin::HtmlParser

Inherits:
Object
  • Object
show all
Defined in:
lib/openfire_admin/html_parser.rb

Overview

html parser wrapper

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ HtmlParser

parse html and build xml

Parameters:

  • html (String)


43
44
45
46
# File 'lib/openfire_admin/html_parser.rb', line 43

def initialize(html)
  @doc = REHTML.to_rexml(html)
  @doc.extend(ElementHelper)
end

Instance Method Details

#at(xpath) ⇒ REXML::Element extends ElementHelper

find first element by xpath

Parameters:

  • xpath (String)

Returns:



58
59
60
# File 'lib/openfire_admin/html_parser.rb', line 58

def at(xpath)
  @doc.at(xpath)
end

#search(xpath, &proc) ⇒ Array<REXML::Element extends ElementHelper>

find elements by xpath

Parameters:

  • xpath (String)

Returns:



51
52
53
# File 'lib/openfire_admin/html_parser.rb', line 51

def search(xpath, &proc)
  @doc.search(xpath, &proc)
end