Class: ROXML::XML::Node
- Includes:
- NamespacedSearch
- Defined in:
- lib/roxml/xml.rb,
lib/roxml/xml/parsers/rexml.rb,
lib/roxml/xml/parsers/libxml.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from(data) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/roxml/xml.rb', line 15 def self.from(data) if data.is_a?(XML::Node) data elsif data.is_a?(File) || data.is_a?(IO) Parser.parse_io(data).root elsif (defined?(URI) && data.is_a?(URI::Generic)) || (defined?(Pathname) && data.is_a?(Pathname)) Parser.parse_file(data.to_s).root else Parser.parse(data).root end end |
.new_cdata(content) ⇒ Object
10 11 12 |
# File 'lib/roxml/xml/parsers/rexml.rb', line 10 def new_cdata(content) REXML::CData.new(content) end |
.new_element(name) ⇒ Object
14 15 16 17 |
# File 'lib/roxml/xml/parsers/rexml.rb', line 14 def new_element(name) name = name.id2name if name.is_a? Symbol REXML::Element.new(name) end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 |
# File 'lib/roxml/xml/parsers/rexml.rb', line 38 def ==(other) to_s == other.to_s end |
#child_add(element) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/roxml/xml/parsers/rexml.rb', line 30 def child_add(element) if element.is_a?(REXML::CData) REXML::CData.new(element, true, self) else add_element(element) end end |
#search(xpath) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/roxml/xml/parsers/rexml.rb', line 22 def search(xpath) begin REXML::XPath.match(self, xpath) rescue Exception => ex raise ex, xpath end end |